Skip to content

Commit ad82236

Browse files
committed
add migration logic to set statuses
1 parent b8bdc4c commit ad82236

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed

sde_collections/migrations/0072_collection_reindexing_status_reindexinghistory.py

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,87 @@
55
import django.db.models.deletion
66

77

8+
def set_initial_reindexing_status(apps, schema_editor):
9+
Collection = apps.get_model("sde_collections", "Collection")
10+
11+
# List of collections that have been reindexed on LRM dev
12+
reindexed_collections = {
13+
"astrophysics_source_code_library",
14+
"astrophysics_science_division_asd_code_660",
15+
"the_astrophysics_astrochemistry_lab",
16+
"Space_Physics_Data_Facility",
17+
"ppi_node",
18+
"sun_climate_powered_by_solar_irradiance",
19+
"magnetospheric_multiscale_satellites",
20+
"mdscc_deep_space_network",
21+
"voyager",
22+
"f_prime",
23+
"interactive_multiinstrument_database_of_solar_flares",
24+
"cii_hosted_payload_opportunity_online_database",
25+
"national_space_weather_program",
26+
"starchild_a_learning_center_for_young_astronomers",
27+
"nexsci",
28+
"explorer_1",
29+
"the_new_great_observatories",
30+
"nasa_ames_intelligent_systems_division_data",
31+
"tropical_cyclone_information_system_data_repository",
32+
"explorers_and_heliophysics_projects_division",
33+
}
34+
35+
# Define the workflow status values
36+
RESEARCH_IN_PROGRESS = 1
37+
READY_FOR_ENGINEERING = 2
38+
ENGINEERING_IN_PROGRESS = 3
39+
READY_FOR_CURATION = 4
40+
CURATION_IN_PROGRESS = 5
41+
CURATED = 6
42+
QUALITY_FIXED = 7
43+
SECRET_DEPLOYMENT_STARTED = 8
44+
SECRET_DEPLOYMENT_FAILED = 9
45+
READY_FOR_LRM_QUALITY_CHECK = 10
46+
READY_FOR_FINAL_QUALITY_CHECK = 11
47+
QUALITY_CHECK_FAILED = 12
48+
QUALITY_CHECK_PERFECT = 13
49+
MERGE_PENDING = 14
50+
NEEDS_DELETE = 19
51+
52+
# Workflow statuses that should be marked as reindexing not needed
53+
reindexing_not_needed_statuses = [
54+
RESEARCH_IN_PROGRESS,
55+
READY_FOR_ENGINEERING,
56+
ENGINEERING_IN_PROGRESS,
57+
READY_FOR_CURATION,
58+
CURATION_IN_PROGRESS,
59+
CURATED,
60+
QUALITY_FIXED,
61+
SECRET_DEPLOYMENT_STARTED,
62+
SECRET_DEPLOYMENT_FAILED,
63+
READY_FOR_LRM_QUALITY_CHECK,
64+
READY_FOR_FINAL_QUALITY_CHECK,
65+
QUALITY_CHECK_FAILED,
66+
QUALITY_CHECK_PERFECT,
67+
MERGE_PENDING,
68+
NEEDS_DELETE,
69+
]
70+
71+
# Set collections that have been reindexed
72+
Collection.objects.filter(config_folder__in=reindexed_collections).update(reindexing_status=3) # FINISHED
73+
74+
# Set collections that don't need reindexing
75+
Collection.objects.filter(workflow_status__in=reindexing_not_needed_statuses).exclude(
76+
config_folder__in=reindexed_collections
77+
).update(
78+
reindexing_status=1
79+
) # NOT_NEEDED
80+
81+
# All other collections need reindexing
82+
Collection.objects.exclude(config_folder__in=reindexed_collections).exclude(
83+
workflow_status__in=reindexing_not_needed_statuses
84+
).update(
85+
reindexing_status=2
86+
) # NEEDED
87+
88+
889
class Migration(migrations.Migration):
990

1091
dependencies = [
@@ -82,4 +163,5 @@ class Migration(migrations.Migration):
82163
),
83164
],
84165
),
166+
migrations.RunPython(set_initial_reindexing_status),
85167
]

0 commit comments

Comments
 (0)