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

fix: Add Cache Wrapper helper to avoid dataset request duplication #64

Conversation

agatapst
Copy link

SUMMARY

The problem was that datasource and field are requested from API every time (instead of keeping them cached when they have been fetched once). The aim of the PR was to limit the API requests using Cache Wrapper helper.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Before:
dedupe_before

After:
dedupe_after_correct

TEST PLAN

Verify manually.
Create new filter or edit existing one.
Choose datasource and field and check the network if it works the same as presented on the gif.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Changes UI
  • Requires DB Migration.
  • Confirm DB Migration upgrade and downgrade tested.
  • Introduces new feature or API
  • Removes existing feature or API

cc @villebro

@villebro villebro changed the title fix: Add Cache Wrapper helper to avoid datasets requests deduplication fix: Add Cache Wrapper helper to avoid dataset request duplication Dec 16, 2020
Copy link

@villebro villebro left a comment

Choose a reason for hiding this comment

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

This looks good, but it would be great to get a few tests for cacheWrapper, as I'm sure once this goes in others will use it, too. Something like making sure fn is called once with args when the key isn't found, and subsequent calls return the correct value without fn being called, even when args gets parameters that aren't covered by keyFn.

@agatapst agatapst force-pushed the native-filters/fix-datasets-requests-dedupe branch from 9209728 to 4ce3b22 Compare December 17, 2020 11:48
Copy link

@villebro villebro left a comment

Choose a reason for hiding this comment

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

Perfect, this is above and beyond what I had hoped for 🙏 👏

@villebro villebro merged commit 0c80712 into preset-io:native-filters-fast-follow Dec 17, 2020
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.

2 participants