Skip to content

Commit

Permalink
add "total score" and average score to maintainers page
Browse files Browse the repository at this point in the history
  • Loading branch information
mansona committed Feb 26, 2020
1 parent 4548465 commit fcfb368
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/components/total-score.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Total Score: {{this.score}} Average Score: {{this.averageScore}}
24 changes: 24 additions & 0 deletions app/components/total-score.js
Original file line number Diff line number Diff line change
@@ -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);
}
}
1 change: 1 addition & 0 deletions app/templates/maintainers/show.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
{{this.model.name}}
</h1>
<p>{{pluralize-this this.model.addons.length "addon"}} maintained by {{this.model.name}}.</p>
<TotalScore @addons={{this.model.addons}} />
</header>
<AddonList @addons={{this.model.addons}} />
</div>

0 comments on commit fcfb368

Please sign in to comment.