-
-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #890 from kobotoolbox/revisions-to-pr-889
Revise line endings and comments in #889
- Loading branch information
Showing
2 changed files
with
46 additions
and
47 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
text | ||
* text=auto eol=lf |
91 changes: 45 additions & 46 deletions
91
onadata/apps/logger/migrations/0028_populate_daily_xform_counters_for_year.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 |
---|---|---|
@@ -1,46 +1,45 @@ | ||
from django.conf import settings | ||
from django.core.management import call_command | ||
from django.db import migrations | ||
|
||
|
||
def populate_daily_counts_for_year(apps, schema_editor): | ||
if settings.SKIP_HEAVY_MIGRATIONS: | ||
print( | ||
""" | ||
!!! ATTENTION !!! | ||
If you have existing projects you need to run this management command: | ||
> python manage.py populate_submission_counters -f --skip_monthly | ||
Until you do, total usage counts from /api/v2/service_usage and /api/v2/asset_usage will be incorrect | ||
""" | ||
) | ||
else: | ||
print( | ||
""" | ||
This might take a while. If it is too slow, you may want to re-run the | ||
migration with SKIP_HEAVY_MIGRATIONS=True and run the following management command: | ||
> python manage.py populate_submission_counters -f --skip_monthly | ||
Until you do, total usage counts from /api/v2/service_usage and /api/v2/asset_usage will be incorrect | ||
""" | ||
) | ||
call_command('populate_submission_counters', force=True, skip_monthly=True) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('logger', '0027_on_delete_cascade_monthlyxformsubmissioncounter'), | ||
('main', '0010_userprofile_metadata_jsonfield'), | ||
] | ||
|
||
# We don't do anything when migrating in reverse | ||
# Just set DAILY_COUNTER_MAX_DAYS back to 31 and counters will be auto-deleted | ||
operations = [ | ||
migrations.RunPython( | ||
populate_daily_counts_for_year, | ||
migrations.RunPython.noop, | ||
), | ||
] | ||
from django.conf import settings | ||
from django.core.management import call_command | ||
from django.db import migrations | ||
|
||
|
||
def populate_daily_counts_for_year(apps, schema_editor): | ||
if settings.SKIP_HEAVY_MIGRATIONS: | ||
print( | ||
""" | ||
!!! ATTENTION !!! | ||
If you have existing projects, you need to run this management command: | ||
> python manage.py populate_submission_counters -f --skip_monthly | ||
Until you do, total usage counts from the KPI endpoints | ||
/api/v2/service_usage and /api/v2/asset_usage will be incorrect | ||
""" | ||
) | ||
else: | ||
print( | ||
""" | ||
This might take a while. If it is too slow, you may want to re-run the | ||
migration with SKIP_HEAVY_MIGRATIONS=True and run the following management command: | ||
> python manage.py populate_submission_counters -f --skip_monthly | ||
""" | ||
) | ||
call_command('populate_submission_counters', force=True, skip_monthly=True) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('logger', '0027_on_delete_cascade_monthlyxformsubmissioncounter'), | ||
('main', '0010_userprofile_metadata_jsonfield'), | ||
] | ||
|
||
# We don't do anything when migrating in reverse | ||
# Just set DAILY_COUNTER_MAX_DAYS back to 31 and counters will be auto-deleted | ||
operations = [ | ||
migrations.RunPython( | ||
populate_daily_counts_for_year, | ||
migrations.RunPython.noop, | ||
), | ||
] |