Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PCA Resyncing Logic #668

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

PCA Resyncing Logic #668

wants to merge 7 commits into from

Conversation

shiva-menta
Copy link
Contributor

  • 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.

Copy link
Contributor

@AaDalal AaDalal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mostly LGTM, but left some comments I would appreciate if you could look over before you merge

@@ -806,9 +806,7 @@ def test_alert_called_wrong_sem(self, mock_alert):
"sent" in json.loads(res.content)["message"],
)
self.assertFalse(mock_alert.called)
self.assertEqual(1, StatusUpdate.objects.count())
u = StatusUpdate.objects.get()
self.assertFalse(u.alert_sent)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why does this test change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding is this test was kind of flawed from the beginning – it attempts to create a StatusUpdate object with a poorly formatted semester. In the record_update function there is a check after the creation of the object that raises an error if the semester is poorly formatted. When changing it to transaction.atomic(), throwing this error leads to reverting the creation of StatusUpdate, which makes more sense logically anyways, as a StatusUpdate object with a poorly formatted semester doesn't make sense.

section.save()

# Add corresponding status update object
if add_status_update and last_status_update.new_status != course_status:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does resyncing manually, but this means we would have to run this on a corn all the time right? This definitely solves one problem, but we still probably need to do something to fix the underlying issue (why do they mismatch ever?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah agreed, I think it's more of a temporary solution (similar to webhookbackup), that we can use while Penn figured out their problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants