Skip to content

Commit 8592b90

Browse files
authored
Merge pull request #960 from mapswipe/fix/project-delete
Fix/project delete issue fix
2 parents 0c3fcde + 8c8d3c9 commit 8592b90

File tree

16 files changed

+53
-25
lines changed

16 files changed

+53
-25
lines changed

.github/workflows/actions.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
working-directory: ./mapswipe_workers
2323
run: |
2424
python -m pip install --upgrade pip
25-
pip install flake8 black==22.3.0 isort
25+
pip install flake8 black==24.4.2 isort
2626
2727
- name: Code style
2828
working-directory: ./mapswipe_workers
@@ -47,15 +47,15 @@ jobs:
4747
run: |
4848
# Create a mock file for wal-g setup
4949
touch postgres/serviceAccountKey.json
50-
docker-compose up --build --detach postgres
51-
for i in {1..5}; do docker-compose exec -T postgres pg_isready && s=0 && break || s=$? && sleep 5; done; (docker-compose logs postgres && exit $s)
50+
docker compose up --build --detach postgres
51+
for i in {1..5}; do docker compose exec -T postgres pg_isready && s=0 && break || s=$? && sleep 5; done; (docker compose logs postgres && exit $s)
5252
5353
- name: Deploy Firebase Rules and Functions
5454
env:
5555
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
5656
FIREBASE_DB: ${{ secrets.FIREBASE_DB }}
5757
run: |
58-
docker-compose run --rm firebase_deploy sh -c "firebase use $FIREBASE_DB && firebase deploy --token $FIREBASE_TOKEN --only database"
58+
docker compose run --rm firebase_deploy sh -c "firebase use $FIREBASE_DB && firebase deploy --token $FIREBASE_TOKEN --only database"
5959
6060
- name: Decrypt Service Account Key File
6161
working-directory: ./
@@ -78,16 +78,16 @@ jobs:
7878
OSMCHA_API_KEY: ${{ secrets.OSMCHA_API_KEY }}
7979
DJANGO_SECRET_KEY: test-django-secret-key
8080
run: |
81-
docker-compose run --rm mapswipe_workers_creation python -m unittest discover --verbose --start-directory tests/unittests/
82-
docker-compose run --rm mapswipe_workers_creation bash -c 'pip install pytest && pytest -ra -v --durations=10 tests/integration/'
83-
docker-compose run --rm django pytest -ra -v --durations=10
81+
docker compose run --rm mapswipe_workers_creation python -m unittest discover --verbose --start-directory tests/unittests/
82+
docker compose run --rm mapswipe_workers_creation bash -c 'pip install pytest && pytest -ra -v --durations=10 tests/integration/'
83+
docker compose run --rm django pytest -ra -v --durations=10
8484
8585
- name: Django Graphql Schema Check
8686
env:
8787
SOURCE_SCHEMA: './django/schema.graphql'
8888
LATEST_SCHEMA: './django-data/schema-latest.graphql'
8989
run: |
90-
docker-compose run --rm django bash -c 'wait-for-it postgres:5432 && ./manage.py graphql_schema --out /django-data/schema-latest.graphql' &&
90+
docker compose run --rm django bash -c 'wait-for-it postgres:5432 && ./manage.py graphql_schema --out /django-data/schema-latest.graphql' &&
9191
cmp --silent $SOURCE_SCHEMA $LATEST_SCHEMA || {
9292
echo 'The schema.graphql is not up to date with the latest changes. Please update and push latest';
9393
diff $SOURCE_SCHEMA $LATEST_SCHEMA;
@@ -101,7 +101,7 @@ jobs:
101101
POSTGRES_DB: postgres
102102
DJANGO_SECRET_KEY: test-django-secret-key
103103
run: |
104-
docker-compose run --rm django bash -c 'wait-for-it postgres:5432 && ./manage.py makemigrations --check --dry-run' || {
104+
docker compose run --rm django bash -c 'wait-for-it postgres:5432 && ./manage.py makemigrations --check --dry-run' || {
105105
echo 'There are some changes to be reflected in the migration. Make sure to run makemigrations';
106106
exit 1;
107107
}

mapswipe_workers/mapswipe_workers/firebase_to_postgres/archive_project.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Archive a project.
33
"""
4+
45
import re
56
import time
67
from typing import Iterable

mapswipe_workers/mapswipe_workers/firebase_to_postgres/delete_project.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Delete projects.
33
"""
4+
45
import re
56
import time
67
from typing import Iterable

mapswipe_workers/mapswipe_workers/project_types/arbitrary_geometry/project.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ class ArbitraryGeometryProject(BaseProject):
3030
def __init__(self, project_draft: dict) -> None:
3131
super().__init__(project_draft)
3232
self.groups: Dict[str, ArbitraryGeometryGroup] = {}
33-
self.tasks: Dict[
34-
str, List[ArbitraryGeometryTask]
35-
] = {} # dict keys are group ids
33+
self.tasks: Dict[str, List[ArbitraryGeometryTask]] = (
34+
{}
35+
) # dict keys are group ids
3636

3737
# set group size
3838
self.geometry = project_draft["geometry"]

mapswipe_workers/mapswipe_workers/project_types/media_classification/project.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ class MediaClassificationProject(BaseProject):
3636
def __init__(self, project_draft: dict):
3737
super().__init__(project_draft)
3838
self.groups: Dict[str, MediaClassificationGroup] = {}
39-
self.tasks: Dict[
40-
str, List[MediaClassificationTask]
41-
] = {} # dict keys are group ids
39+
self.tasks: Dict[str, List[MediaClassificationTask]] = (
40+
{}
41+
) # dict keys are group ids
4242

4343
self.mediaCredits = project_draft.get("mediaCredits", None)
4444
self.medialist = []

mapswipe_workers/mapswipe_workers/project_types/project.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,13 +566,22 @@ def delete_draft_from_firebase(self):
566566
@staticmethod
567567
def delete_mapping_session_results(project_id):
568568
p_con = auth.postgresDB()
569+
# User data
569570
sql_query = """
570571
DELETE FROM mapping_sessions_results msr
571572
USING mapping_sessions ms
572573
WHERE ms.mapping_session_id = msr.mapping_session_id
573574
AND ms.project_id = %(project_id)s;
574575
"""
575576
p_con.query(sql_query, {"project_id": project_id})
577+
# User Group data
578+
sql_query = """
579+
DELETE FROM mapping_sessions_user_groups msug
580+
USING mapping_sessions ms
581+
WHERE ms.mapping_session_id = msug.mapping_session_id
582+
AND ms.project_id = %(project_id)s;
583+
"""
584+
p_con.query(sql_query, {"project_id": project_id})
576585

577586
@classmethod
578587
def delete_from_postgres(cls, project_id):

mapswipe_workers/mapswipe_workers/project_types/tile_map_service/project.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ class TileMapServiceBaseProject(BaseProject):
4141
def __init__(self, project_draft: dict):
4242
super().__init__(project_draft)
4343
self.groups: Dict[str, TileMapServiceBaseGroup] = {}
44-
self.tasks: Dict[
45-
str, List[TileMapServiceBaseTask]
46-
] = {} # dict keys are group ids
44+
self.tasks: Dict[str, List[TileMapServiceBaseTask]] = (
45+
{}
46+
) # dict keys are group ids
4747

4848
self.geometry = project_draft["geometry"]
4949
self.zoomLevel = int(project_draft.get("zoomLevel", 18))

mapswipe_workers/mapswipe_workers/project_types/tile_map_service/tutorial.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ def __init__(self, tutorial_draft):
2626
super().__init__(tutorial_draft)
2727

2828
self.groups: Dict[str, TileMapServiceBaseGroup] = {}
29-
self.tasks: Dict[
30-
str, List[TileMapServiceBaseTutorialTask]
31-
] = {} # dict keys are group ids
29+
self.tasks: Dict[str, List[TileMapServiceBaseTutorialTask]] = (
30+
{}
31+
) # dict keys are group ids
3232

3333
self.zoomLevel = int(tutorial_draft.get("zoomLevel", 18))
3434
self.tileServer = vars(BaseTileServer(tutorial_draft["tileServer"]))

mapswipe_workers/tests/integration/fixtures/digitization/userGroups/user_group.json renamed to mapswipe_workers/tests/integration/fixtures/digitization/user_groups/user_group.json

File renamed without changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
123 ug1001

0 commit comments

Comments
 (0)