|
3 | 3 | Remove a project and its associated data from TheCombine.
|
4 | 4 |
|
5 | 5 | 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. |
15 | 9 | 3. the project document from the ProjectsCollection;
|
16 | 10 |
|
17 | 11 | To delete a project from the backend, we need to delete:
|
|
25 | 19 |
|
26 | 20 | from combine_app import CombineApp
|
27 | 21 |
|
| 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 | + |
28 | 34 |
|
29 | 35 | def parse_args() -> argparse.Namespace:
|
30 | 36 | """Define command line arguments for parser."""
|
@@ -67,15 +73,9 @@ def main() -> None:
|
67 | 73 | if args.verbose:
|
68 | 74 | print(f"Remove project {project}")
|
69 | 75 | 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: |
77 | 77 | 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: |
79 | 79 | combine.db_cmd(db_delete_from_user_fields(project_id, field))
|
80 | 80 | combine.db_cmd(db_delete_from_projects(project_id))
|
81 | 81 | backend_pod = combine.get_pod_id(CombineApp.Component.Backend)
|
|
0 commit comments