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

Update download request fetching on topic and topic content pages #11391

Merged

Conversation

rtibbles
Copy link
Member

Summary

  • Makes the ContentRequest endpoint accept contentnode_id and contentnode_ids filtering parameters
  • Fetches download requests on the topics page by passing the loaded contentnode_ids and further when doing requests for 'more'
  • Fetches just the download request for the specific resource on the content page
  • Cleans up reactivity on topic content page when a resource is downloaded
  • Fixes an unnoticed bug where the networkDevices map was being filtered on, rather than just being looked up in
  • Refactors the MyDownload page polling behaviour into the downloadRequest composable
  • Reuses this polling behaviour on the TopicsContentPage to ensure we get timely status updates of individual resource downloads

References

Fixes #10564
Fixes #11239

Reviewer guidance

Ensure there are no regressions on the MyDownloads page.
Ensure that Download Requests are properly displayed on the topics page and the topics content page.
Ensure that adding a new download in both places properly updates the frontend in a timely fashion.


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 Oct 11, 2023
@github-actions github-actions bot added DEV: backend Python, databases, networking, filesystem... APP: Learn Re: Learn App (content, quizzes, lessons, etc.) SIZE: medium labels Oct 11, 2023
@rtibbles rtibbles force-pushed the which_downloads_pacifically branch from e59e480 to 65e29c4 Compare October 11, 2023 21:47
Copy link
Member

@marcellamaki marcellamaki left a comment

Choose a reason for hiding this comment

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

I had some questions, but no blockers, just learning questions. Thanks @rtibbles !

const children = topic.children ? topic.children.results : [];
for (const child of children) {
if (child.kind === ContentNodeKinds.TOPIC) {
contentnode_id__in.push(..._getAllDescendantChildren(child));
Copy link
Member

Choose a reason for hiding this comment

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

I know recursion isn't actually all that uncommon, but I do enjoy seeing in the wild where it makes complete sense and not just in a documentation page from my bootcamp classes where I was only understanding it theoretically and felt so confused as a junior dev

};

const fetchRemoteBrowsingContentNodeUserData = topic => {
if (get(isUserLoggedIn) && props.deviceId) {
Copy link
Member

Choose a reason for hiding this comment

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

props.deviceId is this a way to access the props from within setup?

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 the way to access it.

Importantly, the props object is reactive, but if you destructure const { deviceId } = props then the deviceId will not be reactive.

@@ -827,7 +860,7 @@
const parent = parentIndex > -1 ? this.contents[parentIndex] : null;
const more = parent && parent.children && parent.children.more;
if (more) {
if (this.isUserLoggedIn) {
if (this.isUserLoggedIn && !this.deviceId) {
Copy link
Member

Choose a reason for hiding this comment

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

I have seen the existence check on the deviceId in a few files now and I don't really know what it's for

Copy link
Member Author

Choose a reason for hiding this comment

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

If it's not defined then we're not browsing remotely. If it is, we are.

facility: store.getters.currentFacilityId,
status: 'Pending',
status: 'PENDING',
Copy link
Member

Choose a reason for hiding this comment

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

important changes here

downloadRequestMap: {
[CONTENT_ID]: {
id: CONTENT_ID,
status: 'COMPLETED',
Copy link
Member

Choose a reason for hiding this comment

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

this is the sort of thing in a test that I need to remember for some future date, that I can actually put in a test

Copy link
Member

@pcenov pcenov left a comment

Choose a reason for hiding this comment

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

LGTM, no regression issues observed as well.

@rtibbles rtibbles merged commit f5e25aa into learningequality:release-v0.16.x Oct 13, 2023
@rtibbles rtibbles deleted the which_downloads_pacifically branch October 13, 2023 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
APP: Learn Re: Learn App (content, quizzes, lessons, etc.) DEV: backend Python, databases, networking, filesystem... SIZE: medium TODO: needs review Waiting for review
Projects
None yet
3 participants