Skip to content
Permalink
Browse files

Merge pull request #482 from lusbenjamin/date-filter-last-24-hours

date filter last 24 hours
  • Loading branch information...
Manuel-777 committed Jul 18, 2019
2 parents 0495cfe + afca7ba commit 00b8a082b7ffd1aa273afa847047a56089a27790
Showing with 13 additions and 7 deletions.
  1. +1 −0 shared/constants.js
  2. +10 −6 window_main/aggregator.js
  3. +2 −1 window_main/filter-panel.js
@@ -715,6 +715,7 @@ exports.MAIN_SETTINGS = 6;
exports.MAIN_UPDATE = 9;

// Date constants
exports.DATE_LAST_DAY = "Last 24 Hours";
exports.DATE_LAST_30 = "Last 30 Days";
exports.DATE_SEASON = "Current Season";
exports.DATE_ALL_TIME = "All Time";
@@ -3,6 +3,7 @@ const {
COLORS_BRIEF,
DATE_ALL_TIME,
DATE_LAST_30,
DATE_LAST_DAY,
DATE_SEASON
} = require("../shared/constants");
const db = require("../shared/database");
@@ -34,12 +35,8 @@ const SINGLE_MATCH_EVENTS = [
"Traditional_Ladder"
];
const CONSTRUCTED_EVENTS = ["Ladder", "Traditional_Ladder"];
// Date constants
// Archetype constants
const NO_ARCH = "No Archetype";
const now = new Date();
const then = new Date();
then.setDate(now.getDate() - 30);
const DAYS_AGO_30 = then.toISOString();

class Aggregator {
constructor(filters) {
@@ -121,10 +118,17 @@ class Aggregator {
filterDate(_date) {
const { date } = this.filters;
let dateFilter = null;
const now = new Date();
if (date === DATE_SEASON) {
dateFilter = db.season_starts;
} else if (date === DATE_LAST_30) {
dateFilter = DAYS_AGO_30;
const then = new Date();
then.setDate(now.getDate() - 30);
dateFilter = then.toISOString();
} else if (date === DATE_LAST_DAY) {
const then = new Date();
then.setDate(now.getDate() - 1);
dateFilter = then.toISOString();
} else {
dateFilter = date;
}
@@ -2,6 +2,7 @@ const {
COLORS_ALL,
COLORS_BRIEF,
DATE_LAST_30,
DATE_LAST_DAY,
DATE_ALL_TIME,
DATE_SEASON
} = require("../shared/constants");
@@ -125,7 +126,7 @@ class FilterPanel {
dataCont.style.display = "flex";
const dateSelect = createSelect(
dataCont,
[DATE_ALL_TIME, DATE_SEASON, DATE_LAST_30],
[DATE_ALL_TIME, DATE_SEASON, DATE_LAST_30, DATE_LAST_DAY],
this.filters.date,
filter => {
this.filters.date = filter;

0 comments on commit 00b8a08

Please sign in to comment.
You can’t perform that action at this time.