-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This release implements custom rage functionallity and fixes the primary key builder. - Refactor PrimaryKey Builder <https://github.com/victorhqc>. - Implemented Custom Range
- Loading branch information
Jonathan Casarrubias
committed
Apr 1, 2016
1 parent
610e813
commit 40924b8
Showing
9 changed files
with
105 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
'use strict'; | ||
/** | ||
* Stats Builder Dependencies | ||
*/ | ||
var moment = require('moment'); | ||
/** | ||
* Builds Now Time Moment | ||
*/ | ||
module.exports = class NowBuilder { | ||
|
||
constructor(ctx) { this.ctx = ctx; } | ||
|
||
build() { | ||
let now; | ||
switch (this.ctx.params.range) { | ||
case 'daily': | ||
case 'weekly': | ||
case 'monthly': | ||
case 'annual': | ||
now = moment(); | ||
break; | ||
case 'custom': | ||
now = moment(this.ctx.params.custom.end); | ||
break; | ||
} | ||
return now; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
'use strict'; | ||
/** | ||
* Stats Builder Dependencies | ||
*/ | ||
var moment = require('moment'); | ||
/** | ||
* Builds Now Time Moment | ||
*/ | ||
module.exports = class NowBuilder { | ||
|
||
constructor(ctx) { this.ctx = ctx; } | ||
|
||
build() { | ||
let type = this.ctx.params.range; | ||
if (this.ctx.params.range === 'custom') { | ||
let start = moment(this.ctx.params.custom.start); | ||
let end = moment(this.ctx.params.custom.end); | ||
['hour', 'day', 'week', 'month', 'year'].forEach(item => { | ||
let plural = [item, 's'].join(''); | ||
let diff = end.diff(start, plural); | ||
if (diff > 1 && diff < 25) { | ||
type = item === 'week' ? end.diff(start, 'days') : diff; | ||
switch (item) { | ||
case 'hour': type = 'daily'; break; | ||
case 'day': type = 'weekly'; break; | ||
case 'week': type = 'monthly'; break; | ||
case 'month': type = 'annual'; break; | ||
} | ||
} | ||
}); | ||
} | ||
|
||
return type; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters