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

Split ExtendedData type into base data and additional data #546

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

Conversation

cirex-web
Copy link
Contributor

@cirex-web cirex-web commented Feb 2, 2025

Ohayou!

This PR splits API data into its original locations data and any extra status data (the stuff that gets updated every second) into a map from conceptId to data. We then rejoin the two things inside ListPage. Types were updated accordingly. (hopefully to better names this time around...)

<ListPage
extraLocationData={extraLocationData}
locations={locations}
/>

Why?

  • We can now instantiate Fuse when the raw API data is updated rather than making a Fuse object every second when the status for each location gets updated in the interval call.
  • Separation of concerns/more explicit divison, in case people want to add more things to extra location data, like pinned locations or review info.

Bug fixes

  • Removed "No results found" page flash on initial render. (it was because filteredLocations was only updated a render after Fuse was defined, which in turn was only updated a render after locations was populated). I changed everything to useMemo and React now updates everything in one pass-through

The bug:

Screen.Recording.2025-02-01.at.8.08.40.PM.mov
image

Description

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

  • Test A
  • Test B

Test Configuration:

  • Node.js version:
  • Python version:
  • Desktop/Mobile:
  • OS:
  • Browser:

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

…search, fix initial no search results glitch
Copy link

vercel bot commented Feb 2, 2025

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

Name Status Preview Comments Updated (UTC)
cmueats ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 9, 2025 10:29pm

@cirex-web cirex-web changed the title Split ExtendedData type into base data and additional data as a map from conceptId to extra data Split ExtendedData type into base data and additional data Feb 2, 2025
@GhostOf0days
Copy link
Member

Ohayou! プルリクエストありがとうございます。いくつかの試験に集中する必要があるため、今週後半にこれをレビューする予定です。

@cirex-web
Copy link
Contributor Author

cirex-web commented Feb 3, 2025

どうもありがとうございます 🙏

@GhostOf0days GhostOf0days mentioned this pull request Feb 6, 2025
@Adrastopoulos
Copy link
Member

IReadOnlyLocation_FromAPI_PostProcessed: is it PascalCase or SCREAMING_SNAKE_CASE?

@cirex-web
Copy link
Contributor Author

pascal case with underscores - joining it together is rather unreadable IReadOnlyLocationFromAPIPostProcessed

@Adrastopoulos
Copy link
Member

Adrastopoulos commented Feb 6, 2025

I would call it: ReadonlyApiPostProcessedLocation. From our experiences in Java you can always find a way (remember the WebSessionServerOAuth2AuthorizedClientRepository?). Of Course, the most important thing is consistency.

@cirex-web
Copy link
Contributor Author

see wouldn't WebSessionServerOAuth2AuthorizedClientRepository be more readable as WebSessionServer_OAuth2_AuthorizedClientRepository? (or some other split depending on how the classes are structured)

@Adrastopoulos
Copy link
Member

I think readability is subjective - maybe there is research done that can prove me wrong. I think the reason for pure pascal case can be reduced to readability, and consistency with existing convention. Also, with these underscores, you are introducing another point of ambiguity. What is the strategy for determining where underscores go?

I suppose a satisfactory way to end this debate would be to find a scientific paper that proves that one method yields higher accuracy than the other. I wasn't able to find any papers (much less any examples) that mix together snake case and pascal case, though.

@GhostOf0days
Copy link
Member

This was closest I could find of any sort. States that underscores are more readable. I don't think it combines them though. camelCase is close enough to PascalCase.: https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=5521745

@GhostOf0days
Copy link
Member

Same level of accuracy. Drastic reduction in time to read.
Screenshot 2025-02-06 at 6 45 19 PM

@cirex-web
Copy link
Contributor Author

interesting! It would probably be unwise to make everything python underscore case though lol

* style: smoother loading experience

* chore: style cleanup

* chore: remove existing search param

* chore: fix lint

* fix: disable animation when user uses search

* fix: a bit smoother title reveal

* fix: lint

* chore: I think this is a fair solution

* fix: css variable delay refactor and card hover fix

* chore: fix lint

* chore: fix lint

* style: add motion blur

* fix: less blur
@GhostOf0days
Copy link
Member

I guess the styling changes will also be merged here lol.

Copy link
Member

@GhostOf0days GhostOf0days left a comment

Choose a reason for hiding this comment

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

Thank you for the PR. There are two issues.

  1. assertThatLocationsAndExtraLocationDataAreInSync is really long. Can you please shorten in. Maybe assertLocationDataInSync.

  2. There is inconsistency in naming. That is, (IReadOnlyLocation_FromAPI_PreProcessed and IReadOnlyLocation_FromAPI_PostProcessed) vs. (IReadOnlyLocationExtraDataMap and IReadOnlyLocationExtraData). We also should choose one standard as Gabe suggested.

Animation side of changes is good as I mentioned in the other PR.

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