Skip to content

Commit 16bfcc0

Browse files
authored
[maintenance/scripts] In rm_project.py, update collections (#3861)
1 parent 075ee10 commit 16bfcc0

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

maintenance/scripts/rm_project.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,9 @@
33
Remove a project and its associated data from TheCombine.
44
55
To delete a project from the database, we need to delete:
6-
1. documents in the
7-
- FrontierCollection,
8-
- MergeBlacklistCollection,
9-
- UserEditsCollection,
10-
- UserRolesCollection, and
11-
- WordsCollection
12-
with a projectId field that matches the project being deleted;
13-
2. entries in the workedProject and projectRoles arrays in
14-
the UsersCollection that reference the project being deleted.
6+
1. documents in the every collection with entries with a projectId field that matches the project
7+
being deleted;
8+
2. entries in object fields in the UsersCollection that are keyed by project being deleted.
159
3. the project document from the ProjectsCollection;
1610
1711
To delete a project from the backend, we need to delete:
@@ -25,6 +19,18 @@
2519

2620
from combine_app import CombineApp
2721

22+
collections_with_project_id = (
23+
"FrontierCollection",
24+
"MergeBlacklistCollection",
25+
"MergeGraylistCollection",
26+
"SpeakersCollection",
27+
"UserEditsCollection",
28+
"UserRolesCollection",
29+
"WordsCollection",
30+
)
31+
32+
user_fields_with_project_id = ("projectRoles", "workedProjects")
33+
2834

2935
def parse_args() -> argparse.Namespace:
3036
"""Define command line arguments for parser."""
@@ -67,15 +73,9 @@ def main() -> None:
6773
if args.verbose:
6874
print(f"Remove project {project}")
6975
print(f"Project ID: {project_id}")
70-
for collection in (
71-
"FrontierCollection",
72-
"MergeBlacklistCollection",
73-
"UserEditsCollection",
74-
"UserRolesCollection",
75-
"WordsCollection",
76-
):
76+
for collection in collections_with_project_id:
7777
combine.db_cmd(db_delete_from_collection(project_id, collection))
78-
for field in ("workedProjects", "projectRoles"):
78+
for field in user_fields_with_project_id:
7979
combine.db_cmd(db_delete_from_user_fields(project_id, field))
8080
combine.db_cmd(db_delete_from_projects(project_id))
8181
backend_pod = combine.get_pod_id(CombineApp.Component.Backend)

0 commit comments

Comments
 (0)