aboutsummaryrefslogtreecommitdiffstats
path: root/pysite/migrations/tables/code_jams/v2.py
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_jams/v2.py
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_jams/v2.py')
-rw-r--r--pysite/migrations/tables/code_jams/v2.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/pysite/migrations/tables/code_jams/v2.py b/pysite/migrations/tables/code_jams/v2.py
new file mode 100644
index 00000000..df4752c8
--- /dev/null
+++ b/pysite/migrations/tables/code_jams/v2.py
@@ -0,0 +1,10 @@
+def run(db, table, table_obj):
+ """
+ Clean list of teams from teams that do not exist anymore.
+ """
+ for document in db.get_all(table):
+ for team_id in document["teams"]:
+ if db.get("code_jam_teams", team_id) is None:
+ document["teams"].remove(team_id)
+ db.insert(table, document, conflict="update", durability="soft")
+ db.sync(table)