aboutsummaryrefslogtreecommitdiffstats
path: root/pysite/migrations/tables/code_jam_teams
diff options
context:
space:
mode:
authorGravatar Gareth Coles <[email protected]>2018-06-24 10:44:57 +0100
committerGravatar Gareth Coles <[email protected]>2018-06-24 10:44:57 +0100
commit105edb52dd0af71b1f37f907ed4ad748b9942911 (patch)
tree8634fc7c6a7fd948696f9eb7a73551699c28ff1b /pysite/migrations/tables/code_jam_teams
parent[API] Implement chunk-based user update mechanism (diff)
parentMerge branch 'momo/optimize-teams-list' into 'master' (diff)
Merge remote-tracking branch 'origin/master'
Diffstat (limited to 'pysite/migrations/tables/code_jam_teams')
-rw-r--r--pysite/migrations/tables/code_jam_teams/__init__.py0
-rw-r--r--pysite/migrations/tables/code_jam_teams/v1.py13
2 files changed, 13 insertions, 0 deletions
diff --git a/pysite/migrations/tables/code_jam_teams/__init__.py b/pysite/migrations/tables/code_jam_teams/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/pysite/migrations/tables/code_jam_teams/__init__.py
diff --git a/pysite/migrations/tables/code_jam_teams/v1.py b/pysite/migrations/tables/code_jam_teams/v1.py
new file mode 100644
index 00000000..165d3100
--- /dev/null
+++ b/pysite/migrations/tables/code_jam_teams/v1.py
@@ -0,0 +1,13 @@
+def run(db, table, table_obj):
+ """
+ Associate the ID of each team's code jam (team -> jam)
+ """
+
+ for document in db.get_all(table):
+ if "jam" not in document:
+ # find the code jam containing this team
+ for jam in db.get_all("code_jams"):
+ if document["id"] in jam["teams"]:
+ document["jam"] = jam["number"]
+ db.insert(table, document, conflict="update", durability="soft")
+ db.sync(table)