Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add week ending and week start to grain #191

Merged
merged 3 commits into from
Mar 21, 2016
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions dashed/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,10 @@ def grains(self):
Grain('Time Column', '{col}'),
Grain('week', "date_trunc('week', CAST({col} AS DATE))"),
Grain('month', "date_trunc('month', CAST({col} AS DATE))"),
Grain("week_ending", "date_add('day', 5, "
"date_trunc('week', date_add('day', 1, CAST({col} AS DATE))))"),
Grain("week_start", "date_add('day', -1, "
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the first argument shows as the label in the dropdown, week_start_monday week_ending_sunday would be more clear.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mistercrunch Makes sense. Fixed!

"date_trunc('week', date_add('day', 1, CAST({col} AS DATE))))")
),
'mysql': (
Grain('Time Column', '{col}'),
Expand Down