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

SCC-4193 - Optimize state in bib page #341

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

dgcohen
Copy link
Contributor

@dgcohen dgcohen commented Oct 2, 2024

Ticket:

This PR does the following:

  • Replaces setting of whole Bib in state with numItems and itemTableData, which are the only pieces of data that need to be refreshed.
  • While the Bib model still needs to get re-initialized based on the way new item table data is fetched, it's not necessary to keep the whole bib in state.

How has this been tested?

NA

Accessibility concerns or updates

NA

Checklist:

  • I updated the CHANGELOG with the appropriate information and JIRA ticket number (if applicable).
  • I have added relevant accessibility documentation for this pull request.
  • All new and existing tests passed.

Copy link

vercel bot commented Oct 2, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
research-catalog ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 8, 2024 7:19pm

@dgcohen dgcohen changed the title Scc 4193/optimize state in bib page SCC-4193 - Optimize state in bib page Oct 2, 2024
Copy link
Contributor

@charmingduchess charmingduchess left a comment

Choose a reason for hiding this comment

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

Looks good. I'm wondering if there is a performance issue here as the code stands?

pages/bib/[id]/index.tsx Show resolved Hide resolved
Copy link
Member

@EdwinGuzman EdwinGuzman left a comment

Choose a reason for hiding this comment

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

Looks good just one question

CHANGELOG Outdated
@@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Updated

- Bib page state optimizations (SCC-4193)
Copy link
Member

Choose a reason for hiding this comment

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

Update this once the merge conflicts have been fixed.

Comment on lines -41 to +43
const viewAllLoadingMessage =
bib.getItemsViewAllLoadingMessage(filtersAreApplied)
const viewAllLoadingMessage = `Loading all ${
filtersAreApplied ? "matching" : numItemsTotal
} items. This may take a few moments...`
Copy link
Member

Choose a reason for hiding this comment

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

getItemsViewAllLoadingMessage is only used here, why not change it instead of moving the functionality here? Or at least delete the declaration from the Bib model.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, i removed it in the Bib model since it's only used here, but can add it back if you'd like greater separation of logic from presentation.

Copy link
Member

Choose a reason for hiding this comment

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

Either approach is ok but I brought it up just as a question.

Copy link
Member

@EdwinGuzman EdwinGuzman left a comment

Choose a reason for hiding this comment

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

Just minor update to the changelog

CHANGELOG Outdated Show resolved Hide resolved
Comment on lines -41 to +43
const viewAllLoadingMessage =
bib.getItemsViewAllLoadingMessage(filtersAreApplied)
const viewAllLoadingMessage = `Loading all ${
filtersAreApplied ? "matching" : numItemsTotal
} items. This may take a few moments...`
Copy link
Member

Choose a reason for hiding this comment

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

Either approach is ok but I brought it up just as a question.

@dgcohen
Copy link
Contributor Author

dgcohen commented Oct 9, 2024

Looks good. I'm wondering if there is a performance issue here as the code stands?

Nothing noticeable but Edwin suggested this change because we don't need to refresh the whole bib in state. @EdwinGuzman would it be worth performing benchmark tests to see if this is necessary?

@EdwinGuzman
Copy link
Member

@dgcohen yes, that'd be great. How about we keep this on hold for a bit and you run some perf tests (lighthouse or another tool) with the current site against this PR? The difference may be negligible but code-wise, I think this is a helpful update.

@charmingduchess charmingduchess removed their request for review December 10, 2024 18:59
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.

3 participants