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

Scheduled syncing updates #10748

Merged
merged 11 commits into from
Jun 7, 2023

Conversation

rtibbles
Copy link
Member

@rtibbles rtibbles commented May 25, 2023

Summary

  • Updates the scheduled syncing code to use the updated backend from Allow update and delete of scheduled tasks #10724 to:
    • Update enqueue arguments
    • Delete scheduled tasks
  • Also updates a lot of frontend logic to repopulate the data for the EditDeviceSyncSchedule component to allow properly editing the task based on existing enqueue arguments
  • Updates handling of date times in the frontend to better display and internationalize using vue-intl utilities
  • Updates the SyncFacilityModalGroup component to include handling of registration to KDP to avoid replicating logic across three different parts of the app
  • Integrates the updated SyncFacilityModalGroup into ManageSyncSchedule to leverage facility specific filtering and syncing to KDP
  • Adds support for syncing to KDP within the Sync schedule components

References

Fixes #10490

Reviewer guidance

Schedule, edit, and delete scheduled syncs using the UI in both the Device plugin and the Facilities plugin.

Screencast.from.05-24-2023.05.12.25.PM.webm

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

@rtibbles rtibbles added the TODO: needs review Waiting for review label May 25, 2023
@github-actions github-actions bot added APP: Device Re: Device App (content import/export, facility-syncing, user permissions, etc.) APP: Facility Re: Facility App (user/class management, facility settings, csv import/export, etc.) SIZE: large labels May 25, 2023
const activeSyncTasks = this.facilityTasks.filter(
t =>
isSyncTask(t) &&
((t.repeat !== null && !t.clearable) ||
Copy link
Member

Choose a reason for hiding this comment

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

None blocking comment: I am wondering if we could introduce intermediate variables with descriptive names to improve code readability. Something like

 const isSync = isSyncTask(task);
  const isRepeatableNonClearable = task.repeat !== null && !task.clearable;

So that instead of using a complex logical expression, the return statement in the filter() method utilizes the intermediate variable

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I think this functional style can be a bit hard to read and intermediary variables can help. I mostly didn't do that because it was like that when I got here! I'll leave for now, but I think worth thinking about when we do further reworking of the frontend task handling (which I have some overall ideas on how we can migrate to a dedicated composable).

Copy link
Member

Choose a reason for hiding this comment

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

I am wondering why whenever I try to edit task scheduled for an hour it become inactive?

Uploading Screen Recording 2023-05-25 at 15.19.00.mov…

Copy link
Member Author

Choose a reason for hiding this comment

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

This is because the tasks scheduled on the hour immediately sync - and because of backend complexities, we can't edit currently running tasks. I think this could probably use some user experience improvements, but also wasn't quite sure the best way to manage it without string updates too.

AllanOXDi
AllanOXDi previously approved these changes May 25, 2023
@@ -90,6 +99,13 @@
}
});
},
cancel() {
if (this.alreadyRegistered && this.successOnAlreadyRegistered) {
Copy link
Member

Choose a reason for hiding this comment

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

If a facility tries to re-register to a project they are already registered to, should there be a check to see if it is already registered with the project before submission, which would change this data prop alreadyRegistered to true? Or is this line only meant to catch the error if the facility is found to already be registered?

I'm asking because the parts where alreadyRegistered is used in the template are never really shown and could be removed. I manipulated the data in Vue.js devtools to see this view.

Screenshot 2023-05-25 at 3 46 48 PM

Copy link
Member Author

Choose a reason for hiding this comment

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

This is only meant to catch the case where there is an error with registration due to the facility already being registered to KDP.

In the case where we are directly doing a registration action by using the Register option from the dot menu, this emits a 'cancel' event. In the case that I am using it here, I wanted it to instead emit a success event in this case, as it is fine to carry on and try to sync to KDP because it is already registered, so this logic is intended to be handling that.

@pcenov pcenov added the gherkin update An issue that only requires updating Gherkin stories for a feature label May 29, 2023
@pcenov
Copy link
Member

pcenov commented May 30, 2023

Hi @rtibbles here are some minor issues I was able to identify while testing the scheduled syncing:

  1. When a sync is happening while one is at the Facilities page, the 'Last synced' value doesn't update unless I manually refresh the page:
KDP.Sync.mp4
  1. The status of a KDP schedule is always displayed as 'Not connected' and there's always an error in the console which states: Cannot read properties of undefined (reading 'device name')

2023-05-30_13-56-21

  1. For some reason there are 2 tasks in the task manager which always show as incomplete (I'll let you know if I find specific steps to replicate that one):

2023-05-30_16-32-43

@rtibbles rtibbles dismissed AllanOXDi’s stale review May 30, 2023 15:19

Going to dismiss this for now until we get QA sign off!

@rtibbles
Copy link
Member Author

Thanks Peter - I think issue 1 is an existing issue, so let's file that as a follow up.

For issue 2, I'll hide the connection status for KDP, and we can update that when we have better connection tracking for KDP once #10431 is resolved.

For issue 3, I'll tweak to make this less weird.

@rtibbles
Copy link
Member Author

2 should now be fixed:
Screenshot from 2023-05-30 13-20-27

3 should now be better:
Screenshot from 2023-05-30 13-17-54

@pcenov
Copy link
Member

pcenov commented May 31, 2023

@rtibbles I confirm that 2 and 3 are fixed now and have filed a follow-up issue for 1 here: #10759

I also noticed that if I lose my internet connection or I stop the server for a facility for which I have scheduled a sync, the line in the table completely disappears instead of seeing the 'Not connected' status:

2023-05-31_14-30-15.mp4

A somewhat similar issue can be observed at Facility > Data > Manage sync schedule where after editing the schedule the entry disappears:

2023-05-31_16-29-18.mp4

@rtibbles
Copy link
Member Author

Thanks @pcenov - that's a good catch, I'll update to fix this.

@rtibbles
Copy link
Member Author

rtibbles commented Jun 1, 2023

I think this should now be fixed.

Screenshot from 2023-06-01 12-04-54

@pcenov
Copy link
Member

pcenov commented Jun 2, 2023

Hi @rtibbles, I confirm that now if I stop the server of a facility for which I have a scheduled sync that is reflected correctly in the status which changes first to 'Not connected' and then back to 'Connected' once I've restarted the server. However if I turn off my wi-fi and then turn it on, the status remains 'Not connected' until I manually restart the server.

2023-06-02_17-54-09.mp4

Also this issue is still not fixed:

"A somewhat similar issue can be observed at Facility > Data > Manage sync schedule where after editing the schedule the entry disappears:"

2023-05-31_16-29-18.mp4

Lastly, one new very minor issue which we've missed so far - the 'Frequency' drop-down is incorrectly labeled 'Frequence'

I can of course file those as separate issues if you wish.

@rtibbles
Copy link
Member Author

rtibbles commented Jun 2, 2023

Lastly, one new very minor issue which we've missed so far - the 'Frequency' drop-down is incorrectly labeled 'Frequence'

This will need to be a separate issue, as we don't have the string to update this, I believe.

@rtibbles
Copy link
Member Author

rtibbles commented Jun 2, 2023

However if I turn off my wi-fi and then turn it on, the status remains 'Not connected' until I manually restart the server.

I think this should be filed as a follow up issue too - seems to be an issue with the connection status being properly updated when the network adapter state changes, so this is rather outside the remit of this PR!

@rtibbles
Copy link
Member Author

rtibbles commented Jun 2, 2023

"A somewhat similar issue can be observed at Facility > Data > Manage sync schedule where after editing the schedule the entry disappears:"

I had foolishly assumed that the previous issue that I fixed and this issue had the same root cause, I'll investigate further now.

@rtibbles
Copy link
Member Author

rtibbles commented Jun 7, 2023

@pcenov this issue:

"A somewhat similar issue can be observed at Facility > Data > Manage sync schedule where after editing the schedule the entry disappears:"

Was actually an issue with any navigation back from the sync edit page or the listing of all syncs page. Now all navigation actions should be working including:

  • Creating a new sync
  • Editing an existing sync
  • Deleting a sync
  • Pressing the X button when editing a sync
  • Cancelling a sync edit
  • Going back from the listing of syncs (should return to the correct Data page for the chosen facility)

@pcenov
Copy link
Member

pcenov commented Jun 7, 2023

Thanks @rtibbles for further investigating and fixing it properly. No new issues observed while regression testing today, LGTM!

Copy link
Member

@radinamatic radinamatic left a comment

Choose a reason for hiding this comment

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

Manual QA passed, good to go! 👏🏽 💯 :shipit:

@rtibbles rtibbles merged commit 3e5861d into learningequality:develop Jun 7, 2023
@rtibbles rtibbles deleted the scheduled_syncing_updates branch June 7, 2023 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
APP: Device Re: Device App (content import/export, facility-syncing, user permissions, etc.) APP: Facility Re: Facility App (user/class management, facility settings, csv import/export, etc.) gherkin update An issue that only requires updating Gherkin stories for a feature SIZE: large TODO: needs review Waiting for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow scheduled sync task to be updated when it has been edited.
5 participants