Skip to content

Commit 2760ec6

Browse files
shiva-mentaluke-rt
authored andcommitted
PCA Resyncing Logic (#668)
- Adding transaction.atomic() wrapper to webhook database calls, to reduce potential consistency errors between our StatusUpdate models and our Section model. This required modifying one of our existing test cases. - Modifying logic for loadstatus management command to conditionally add StatusUpdate objects to ensure consistency between the last StatusUpdate and the status attribute of the Section model. registrarimport also uses loadstatus's logic, but it currently does not add StatusUpdate objects – this can be changed easily by setting add_status_update=True. - Add sync_path_status management command to sync our database with path statuses in the case that OpenData's status API is inaccurate (we've historically seen this for around 4% of courses).
1 parent 0495062 commit 2760ec6

File tree

6 files changed

+380
-100
lines changed

6 files changed

+380
-100
lines changed

backend/Pipfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ python-dateutil = "*"
6363
docutils = "*"
6464
ics = "*"
6565
drf-nested-routers = "*"
66+
asyncio = "*"
67+
aiohttp = "*"
6668

6769
[requires]
6870
python_full_version = "3.11"

backend/Pipfile.lock

Lines changed: 108 additions & 82 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

backend/alert/views.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -132,15 +132,16 @@ def accept_webhook(request):
132132
else:
133133
response = JsonResponse({"message": "webhook recieved"})
134134

135-
u = record_update(
136-
section,
137-
course_term,
138-
prev_status,
139-
course_status,
140-
alert_for_course_called,
141-
request.body,
142-
)
143-
update_course_from_record(u)
135+
with transaction.atomic():
136+
u = record_update(
137+
section,
138+
course_term,
139+
prev_status,
140+
course_status,
141+
alert_for_course_called,
142+
request.body,
143+
)
144+
update_course_from_record(u)
144145
except (ValidationError, ValueError) as e:
145146
logger.error(e, extra={"request": request})
146147
response = JsonResponse(

0 commit comments

Comments
 (0)