diff --git a/app/components/total-score.hbs b/app/components/total-score.hbs new file mode 100644 index 00000000..881521e7 --- /dev/null +++ b/app/components/total-score.hbs @@ -0,0 +1 @@ +Total Score: {{this.score}} Average Score: {{this.averageScore}} \ No newline at end of file diff --git a/app/components/total-score.js b/app/components/total-score.js new file mode 100644 index 00000000..5e638e2c --- /dev/null +++ b/app/components/total-score.js @@ -0,0 +1,24 @@ +import Component from '@glimmer/component'; + +export default class TotalScoreComponent extends Component { + get score() { + if(!this.args.addons.length) { + return 0; + } + + let score = this.args.addons.reduce((total, currentAddon) => { + return currentAddon.score + total; + }, 0); + + return score.toFixed(1); + } + + get averageScore() { + if (!this.score || !this.args.addons.length){ + return 0; + } + + let average = this.score / this.args.addons.length; + return average.toFixed(1); + } +} diff --git a/app/templates/maintainers/show.hbs b/app/templates/maintainers/show.hbs index 0e566285..e1606b22 100644 --- a/app/templates/maintainers/show.hbs +++ b/app/templates/maintainers/show.hbs @@ -5,6 +5,7 @@ {{this.model.name}}

{{pluralize-this this.model.addons.length "addon"}} maintained by {{this.model.name}}.

+