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

Paginate topics #4616

Merged
merged 4 commits into from
Aug 20, 2024
Merged

Conversation

rtibbles
Copy link
Member

Summary

Description of the change(s) you made

  • Adds simple lft__gt based pagination to contentnode endpoint, only really usable when filtering by parent or tree_id
  • Deletes unused pagination from the resource layer, and adds support for simple single value incrementing (e.g. lft) pagination to it
  • Updates the UI to handle this

Manual verification steps performed

Make a topic with more than 50 children.
Check basic pagination works.
Clear cache and all indexedDB.
Load one additional page (so there should still be one more).
Reload the page.
Turn off the network connection in the network tab of the browser.
Press show more.
See that the additional page loads from indexedDB, and that even though there are no more nodes in IndexedDB, the cached pagination result allows 'show more' to still be shown.
Turn the network back on and press show more to see the remainder.

Screenshot

Screenshot from 2024-07-23 09-30-00

References

Fixes #1280

Comments


Contributor's Checklist

PR process:

  • If this is an important user-facing change, PR or related issue the CHANGELOG label been added to this PR. Note: items with this label will be added to the CHANGELOG at a later time
  • If this includes an internal dependency change, a link to the diff is provided
  • The docs label has been added if this introduces a change that needs to be updated in the user docs?
  • If any Python requirements have changed, the updated requirements.txt files also included in this PR
  • Opportunities for using Google Analytics here are noted
  • Migrations are safe for a large db

Studio-specifc:

  • All user-facing strings are translated properly
  • The notranslate class been added to elements that shouldn't be translated by Google Chrome's automatic translation feature (e.g. icons, user-generated text)
  • All UI components are LTR and RTL compliant
  • Views are organized into pages, components, and layouts directories as described in the docs
  • Users' storage used is recalculated properly on any changes to main tree files
  • If there new ways this uses user data that needs to be factored into our Privacy Policy, it has been noted.

Testing:

  • Code is clean and well-commented
  • 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
  • Any new interactions have been added to the QA Sheet
  • Critical and brittle code paths are covered by unit tests

Reviewer's Checklist

This section is for reviewers to fill out.

  • 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

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.

Did first code read through and had a couple of comprehension questions, mostly because I'm lacking some context and familiarity with the code. I'll do a manual QA review and then a re-read of the code after that.

// A special table for logging unsynced changes
// Dexie.js appears to have a table for this,
// but it seems to squash and remove changes in ways
// that I do not currently understand, so we engage
// in somewhat duplicative behaviour instead.
[CHANGES_TABLE]: 'rev++,[table+key],server_rev',
[PAGINATION_TABLE]: 'queryString',
Copy link
Member

Choose a reason for hiding this comment

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

how do i know this is supposed to be 'queryString'? not rhetorical, just wondering what I should look into to understand the syntax/intention here. I did a quick repo search and didn't see anything similar. I can infer what's happening but just unfamiliar with the specifics of this file

Copy link
Member Author

Choose a reason for hiding this comment

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

The string for each table is a comma separated list of indexed properties, with the first listed one being the primary key. As we are caching the results of paginated queries, the queryString should uniquely identify the request in question. Although perhaps, I should have called it 'queryURL' as I think that's more what I am using, I think (if I'm not, that's a good thing to pull me up on).

Copy link
Member Author

Choose a reason for hiding this comment

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

Hrm, it does rather look like I forgot to add the table or API endpoint into this, so I'll need to update that (even though we are only currently paginating ContentNode).

Copy link
Member Author

Choose a reason for hiding this comment

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

Have updated this now so that the primary key is a compound key of the table and the querystring, and updated the querying and saving accordingly too.

return collection.toArray();
}

whereLiveQuery(params = {}) {
Copy link
Member

Choose a reason for hiding this comment

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

why is liveQuery needed here?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's not - I started trying to implement the pagination stuff using liveQuery to make sure it would be compatible, then realized I was doing more than was necessary for the immediate fix - then left these helper functions in here as generally useful, when I had originally intended to separate them out into a separate PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

I left this in, because it does no harm, and it's useful tiny flyby refactor.

<template #pagination>
<div class="pagination-container">
<KButton v-if="more" :disabled="moreLoading" @click="loadMore">
{{ 'Show more' }}
Copy link
Member

Choose a reason for hiding this comment

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

String on the lose

Copy link
Member Author

Choose a reason for hiding this comment

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

I had a dream that this was the case - it seems my dreams came true!

@rtibbles rtibbles merged commit 892ab07 into learningequality:unstable Aug 20, 2024
13 checks passed
@rtibbles rtibbles deleted the paginate_topics branch August 20, 2024 19:13
@akolson akolson mentioned this pull request Aug 24, 2024
@radinamatic
Copy link
Member

Not having luck trying to load more pages after clearing cache and all indexedDB, and I'm seeing some Sentry errors in the Network tab 😕

pagination

@rtibbles
Copy link
Member Author

Ah yes, there's a bug here, that I've fixed in a follow up PR.

@akolson akolson mentioned this pull request Oct 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Topic display UI needs pagination
3 participants