diff options
author | 2018-06-23 18:08:16 -0400 | |
---|---|---|
committer | 2018-06-23 18:08:16 -0400 | |
commit | 2734934c3c21e46c22a967a9a69713d418269e55 (patch) | |
tree | 8921e33ab5ab7bf64cfb7f9aa6e2c8db749d9fe7 /pysite/migrations/tables/code_jams/v2.py | |
parent | [Jams/Teams] Simplify getting the code jam for a team (team -> jam) (diff) |
[Jams/Teams] De-associate delete teams from jams
Diffstat (limited to 'pysite/migrations/tables/code_jams/v2.py')
-rw-r--r-- | pysite/migrations/tables/code_jams/v2.py | 10 |
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) |