From 63148d86aa3dc8894c5a506232ec1037dbf4f2d3 Mon Sep 17 00:00:00 2001 From: Chris Manson Date: Wed, 26 Feb 2020 08:00:27 +0000 Subject: [PATCH] add "total score" and average score to maintainers page --- app/components/total-score.hbs | 1 + app/components/total-score.js | 24 ++++++++++++++++++++++++ app/templates/maintainers/show.hbs | 1 + 3 files changed, 26 insertions(+) create mode 100644 app/components/total-score.hbs create mode 100644 app/components/total-score.js 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}}.

+