Skip to content

Commit

Permalink
Merge pull request #890 from kobotoolbox/revisions-to-pr-889
Browse files Browse the repository at this point in the history
Revise line endings and comments in #889
  • Loading branch information
LMNTL committed Aug 22, 2023
2 parents d5bb016 + 5ed9acc commit 5a0d890
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 47 deletions.
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1 @@
text
* text=auto eol=lf
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,
),
]

0 comments on commit 5a0d890

Please sign in to comment.