summaryrefslogtreecommitdiff
path: root/src/report-service.js
blob: feddec56fc62a483786e4d03c84b1bb6d2b97cf0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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];
  }
}