Skip to content

Commit 3feb640

Browse files
committed
Add missing references in mapping_sessions_user_groups
- Update documentations
1 parent 2f56330 commit 3feb640

File tree

7 files changed

+15
-9
lines changed

7 files changed

+15
-9
lines changed

.github/workflows/actions.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
- name: Assert check
3131
run: |
3232
cmp --silent ./postgres/initdb.sql ./mapswipe_workers/tests/integration/set_up_db.sql || {
33-
echo 'The set_up_db.sql is not same as initdb.sql. Please do `cp ./postgres/initdb.sql ./mapswipe_workers/tests/integration/set_up_db.sql` and push';
33+
echo 'The set_up_db.sql is not same as initdb.sql. Please sync this files and push';
3434
diff ./postgres/initdb.sql ./mapswipe_workers/tests/integration/set_up_db.sql;
3535
exit 1;
3636
}

django/apps/existing_database/migrations/0001_initial.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ class Migration(migrations.Migration):
102102
("timestamp", models.DateTimeField(blank=True, null=True)),
103103
("start_time", models.DateTimeField(blank=True, null=True)),
104104
("end_time", models.DateTimeField(blank=True, null=True)),
105-
("result", models.IntegerField(blank=True, null=True)),
105+
("result", models.SmallIntegerField(blank=True, null=True)),
106106
],
107107
options={
108108
"db_table": "results",

django/apps/existing_database/migrations/0002_mappingsession_mappingsessionresult.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class Migration(migrations.Migration):
3636
fields=[
3737
("mapping_session_id", models.BigIntegerField()),
3838
("task_id", models.CharField(max_length=999)),
39-
("result", models.IntegerField(blank=True, null=True)),
39+
("result", models.SmallIntegerField(blank=True, null=True)),
4040
],
4141
options={
4242
"db_table": "mapping_sessions_results",

django/apps/existing_database/models.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
from django.db import models
33
from mapswipe.db import Model
44

5+
# NOTE: Django model defination and existing table structure doesn't entirely matches.
6+
# This is to be used for testing only.
7+
58

69
class User(Model):
710
user_id = models.CharField(primary_key=True, max_length=999)
@@ -152,7 +155,7 @@ class Result(Model):
152155
timestamp = models.DateTimeField(blank=True, null=True)
153156
start_time = models.DateTimeField(blank=True, null=True)
154157
end_time = models.DateTimeField(blank=True, null=True)
155-
result = models.IntegerField(blank=True, null=True)
158+
result = models.SmallIntegerField(blank=True, null=True)
156159

157160
# Django derived fields from ForeignKey
158161
project_id: str
@@ -237,7 +240,7 @@ class Meta:
237240
class MappingSessionResult(Model):
238241
mapping_session = models.ForeignKey(MappingSession, on_delete=models.DO_NOTHING)
239242
task_id = models.CharField(max_length=999)
240-
result = models.IntegerField(blank=True, null=True)
243+
result = models.SmallIntegerField(blank=True, null=True)
241244

242245
class Meta:
243246
managed = False
@@ -254,4 +257,4 @@ class MappingSessionUserGroup(Model):
254257
class Meta:
255258
managed = False
256259
db_table = "mapping_sessions_user_groups"
257-
unique_together = (("mapping_session", "user_group_id"),)
260+
unique_together = (("mapping_session", "user_group"),)

django/mapswipe/utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,10 @@ def fetch_git_sha(path, head=None):
5858
return str(fh.read()).strip()
5959

6060

61-
def raise_if_field_not_found(obj, fields, custom_exception=Exception):
61+
def raise_if_field_not_found(obj: dict, fields: list[str], custom_exception=Exception):
6262
"""
6363
NOTE: This is for making sure dev pass this variables manually in the test.
64+
Don't catch this exception
6465
"""
6566
empty_keys = [field for field in fields if obj.get(field) is None]
6667
if empty_keys:

mapswipe_workers/tests/integration/set_up_db.sql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,8 @@ CREATE TABLE IF NOT EXISTS mapping_sessions_user_groups (
212212
mapping_session_id int8,
213213
user_group_id varchar, -- user group primary key
214214
PRIMARY KEY (mapping_session_id, user_group_id),
215-
FOREIGN KEY (mapping_session_id) REFERENCES mapping_sessions (mapping_session_id)
215+
FOREIGN KEY (mapping_session_id) REFERENCES mapping_sessions (mapping_session_id),
216+
FOREIGN KEY (user_group_id) REFERENCES user_groups (user_group_id)
216217
);
217218

218219
-- create table for user_group_results import through csv

postgres/initdb.sql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,8 @@ CREATE TABLE IF NOT EXISTS mapping_sessions_user_groups (
212212
mapping_session_id int8,
213213
user_group_id varchar, -- user group primary key
214214
PRIMARY KEY (mapping_session_id, user_group_id),
215-
FOREIGN KEY (mapping_session_id) REFERENCES mapping_sessions (mapping_session_id)
215+
FOREIGN KEY (mapping_session_id) REFERENCES mapping_sessions (mapping_session_id),
216+
FOREIGN KEY (user_group_id) REFERENCES user_groups (user_group_id)
216217
);
217218

218219
-- create table for user_group_results import through csv

0 commit comments

Comments
 (0)