Skip to content

Commit

Permalink
Clear out unaligned NLCD19 GWLF-E results
Browse files Browse the repository at this point in the history
Adds a migration that clears out all stored results for GWLF-E
projects created on or after 2022-01-17, which is when 1.33.0
was released with incorrectly aligned NLCD19 layers, which had
also been made the default. Thus, every project made after then
had slighly incorrect results.

This migration clears out those bad results. The next time that
project is loaded in the UI, all its results will be recalculated.
This allows us to rebuild the results over time, and not overload
the system all at once.
  • Loading branch information
rajadain committed Oct 17, 2022
1 parent fc3a3b7 commit 3fd4244
Showing 1 changed file with 45 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Generated by Django 3.2.13 on 2022-10-17 13:47

from django.db import migrations


def clear_nlcd2019_gwlfe_results(apps, schema_editor):
"""
Clear the results for all scenarios belonging to GWLF-E projects made after
the release of 1.33.0, which had incorrectly aligned NLCD19 2019 on
2022-01-17:
https://github.com/WikiWatershed/model-my-watershed/releases/tag/1.33.0
These results will be recalculated with the correclty aligned NLCD19 values
when these projects are accessed again.
"""
Project = apps.get_model('modeling', 'Project')
Scenario = apps.get_model('modeling', 'Scenario')

Project.objects.filter(
model_package='gwlfe',
created_at__gte='2022-01-17',
).update(
gis_data=None,
mapshed_job_uuid=None,
subbasin_mapshed_job_uuid=None,
)

Scenario.objects.filter(
project__model_package='gwlfe',
project__created_at__gte='2022-01-17',
).update(
results='[]',
modification_hash='',
)


class Migration(migrations.Migration):

dependencies = [
('modeling', '0040_clear_nlcd2019_tr55_results'),
]

operations = [
migrations.RunPython(clear_nlcd2019_gwlfe_results),
]

0 comments on commit 3fd4244

Please sign in to comment.