Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixes bug 1201270 - backfill last 28 days of signature_summary_os, r=…
…twobraids
- Loading branch information
Showing
1 changed file
with
47 additions
and
0 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
alembic/versions/16b2bee7db72_backfill_signature_summary_os_28_days.py
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,47 @@ | ||
"""backfill signature_summary_os 28 days | ||
Revision ID: 16b2bee7db72 | ||
Revises: 4afd4e13281d | ||
Create Date: 2015-09-02 13:53:13.505082 | ||
""" | ||
import datetime | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = '16b2bee7db72' | ||
down_revision = '4afd4e13281d' | ||
|
||
from alembic import op | ||
|
||
|
||
def upgrade(): | ||
# We only ever, at most, show 28 days in the report list that | ||
# shows this signature summary. | ||
today = datetime.datetime.utcnow().date() | ||
for i in range(28, 0, -1): | ||
then = today - datetime.timedelta(days=i) | ||
till = then + datetime.timedelta(days=1) | ||
op.execute( | ||
""" | ||
SELECT | ||
backfill_weekly_report_partitions( | ||
'%s', '%s', 'signature_summary_os' | ||
) | ||
""" % ( | ||
then.strftime('%Y-%m-%d'), | ||
till.strftime('%Y-%m-%d') | ||
) | ||
) | ||
op.execute( | ||
""" | ||
SELECT | ||
update_signature_summary_os('%s') | ||
""" % ( | ||
then.strftime('%Y-%m-%d'), | ||
) | ||
) | ||
op.execute('COMMIT') | ||
|
||
|
||
def downgrade(): | ||
pass |