From 2f225a54054ae44df2d8fa691efcf247a82f94a1 Mon Sep 17 00:00:00 2001 From: schneefux Date: Fri, 11 May 2018 20:21:18 +0200 Subject: refactor: create ReportService, move tabs to component --- src/App.vue | 61 +++++++++---------------------------------------- src/BattleRoyaleTab.vue | 26 +++++++++++++++++++++ src/BlitzTab.vue | 48 ++++++++++++++++++++++++++++++++++++++ src/report-service.js | 37 ++++++++++++++++++++++++++++++ 4 files changed, 122 insertions(+), 50 deletions(-) create mode 100644 src/BattleRoyaleTab.vue create mode 100644 src/BlitzTab.vue create mode 100644 src/report-service.js (limited to 'src') diff --git a/src/App.vue b/src/App.vue index a994a01..aa2d19c 100644 --- a/src/App.vue +++ b/src/App.vue @@ -9,75 +9,36 @@ - + -
-
- - {{ Math.round(100 * topWins.blitz_pvp_ranked.Winner) }}% Win Rate - -
- -
- - {{ (100 * 6 * topPicks.blitz_pvp_ranked.Count / totalPicks.blitz_pvp_ranked).toFixed(2) }}% Pick Rate - -
-
- -

Blitz Hero Statistics

- +
-

Battle Royale Hero Statistics

- +
diff --git a/src/BattleRoyaleTab.vue b/src/BattleRoyaleTab.vue new file mode 100644 index 0000000..48d8b25 --- /dev/null +++ b/src/BattleRoyaleTab.vue @@ -0,0 +1,26 @@ + + + diff --git a/src/BlitzTab.vue b/src/BlitzTab.vue new file mode 100644 index 0000000..5d711a2 --- /dev/null +++ b/src/BlitzTab.vue @@ -0,0 +1,48 @@ + + + diff --git a/src/report-service.js b/src/report-service.js new file mode 100644 index 0000000..feddec5 --- /dev/null +++ b/src/report-service.js @@ -0,0 +1,37 @@ +const MODES = [ 'casual_aral', 'blitz_pvp_ranked' ]; + +export default class ReportService { + constructor() { + this.report = require('../data/98aae7f0/report.json'); + + this.reports = {}; + this.totalPicks = {}; + this.topPicks = {}; + this.topWins = {}; + + for(let mode of MODES) { + this.reports[mode] = this.report.filter((entry) => entry.Mode == mode); + this.totalPicks[mode] = this.report.map((entry) => entry.Count).reduce((agg, cur) => agg + cur, 0); + this.topPicks[mode] = this.reports[mode].sort((entry1, entry2) => entry2.Count - entry1.Count)[0]; + this.topWins[mode] = this.reports[mode] + .filter((entry) => 100 * 6 * entry.Count / this.totalPicks[mode] > 0.05) + .sort((entry1, entry2) => entry2.Winner - entry1.Winner)[0]; + } + } + + getReport(mode) { + return this.reports[mode]; + } + + getTotalPicks(mode) { + return this.totalPicks[mode]; + } + + getTopPick(mode) { + return this.topPicks[mode]; + } + + getTopWin(mode) { + return this.topWins[mode]; + } +} -- cgit v1.3.1