kolibri icon indicating copy to clipboard operation
kolibri copied to clipboard

Learner devices status update

Open rtibbles opened this issue 1 year ago • 3 comments

Summary

  • Turns the learner device status user field to a ForeignKey rather than OneToOne field to prevent errors when trying to create learner device statuses for the same learner for syncs from multiple devices
  • Adds sync hook to selectively delete LearnerDeviceStatus to prevent trying to sync more than one LearnerDeviceStatus for a single user to another device.

References

Fixes #12043

Reviewer guidance

The logic is relatively straight forward, I think - I am just not sure how to do any sort of test of this change, especially the version sync hook.


Testing checklist

  • [ ] Contributor has fully tested the PR manually
  • [ ] If there are any front-end changes, before/after screenshots are included
  • [ ] Critical user journeys are covered by Gherkin stories
  • [ ] Critical and brittle code paths are covered by unit tests

PR process

  • [ ] PR has the correct target branch and milestone
  • [ ] PR has 'needs review' or 'work-in-progress' label
  • [ ] If PR is ready for review, a reviewer has been added. (Don't use 'Assignees')
  • [ ] If this is an important user-facing change, PR or related issue has a 'changelog' label
  • [ ] If this includes an internal dependency change, a link to the diff is provided

Reviewer checklist

  • Automated test coverage is satisfactory
  • PR is fully functional
  • PR has been tested for accessibility regressions
  • External dependency files were updated if necessary (yarn and pip)
  • Documentation is updated
  • Contributor is in AUTHORS.md

:rocket: This description was created by Ellipsis for commit 2d91ec9f5a35fc65a39d5abf078afaa1f5082b8d

Summary:

This PR updates the LearnerDeviceStatus model to support multiple device statuses per user and adds a sync operation to manage data consistency across device syncs.

Key points:

  • Changed LearnerDeviceStatus.user from OneToOneField to ForeignKey.
  • Added LearnerDeviceStatusOperation to handle deletion of problematic LearnerDeviceStatus records during sync.
  • Introduced LearnerDeviceStatusHook to trigger the new operation during sync.
  • Added migration 0022_learner_device_status_multiple_devices.py for database schema update.

Generated with :heart: by ellipsis.dev

rtibbles avatar May 09 '24 21:05 rtibbles

Hey @ellipsis, give me a code review

rtibbles avatar May 10 '24 05:05 rtibbles

OK! Reviewing this PR...


Responding to this comment by @rtibbles. For more information about Ellipsis, check the documentation.

ellipsis-dev[bot] avatar May 10 '24 05:05 ellipsis-dev[bot]

Hi @rtibbles no issues observed while checking the above described QA scenario - the devices were syncing correctly. I do see some errors in the server logs so posting these here for you in case you find anything that needs to be fixed:

logs-and-db.zip

pcenov avatar May 15 '24 14:05 pcenov

Hi @rtibbles no issues observed while checking the above described QA scenario - the devices were syncing correctly. I do see some errors in the server logs so posting these here for you in case you find anything that needs to be fixed:

logs-and-db.zip

Looks like some DB locking errors

bjester avatar May 15 '24 14:05 bjester