-
-
Notifications
You must be signed in to change notification settings - Fork 719
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
Improve effiency of OrderCycle.earliest_closing_times #12745
Improve effiency of OrderCycle.earliest_closing_times #12745
Conversation
It looks like the failing spec is currently because of a rate limit, but hopefully if this is re-run it should pass 🤞🏻 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome ! thank you for looking into this 🙏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great contribution, thank you! ✨
The unit test is good, too. The mocked data has the disadvantage of not simulating the data types returned from the database, e.g. testing to_time
but it's better than before.
For testing:
|
Hi @johansenja, I have tested it on our UK staging server and couldn't spot any difference, which is good in this case, I think. All data is there, the page is loading correctly. I can't really comment on the performance of the page. Here are some screenshots (identical before and after): Since no issues can be observed I trust in you and our reviews and I will go ahead and merge. 🚀 |
What? Why?
When visiting https://openfoodnetwork.org.uk/shops, the page load is very slow. Given that this page is linked to from the
CTA above the fold on https://openfoodnetwork.org.uk/, it seems ideal that should load quickly.
From my testing so far, it is significantly quicker to calculate the open shops by using
pluck
instead of aselect
andmap
- pluck uses less computation and memory, because it pulls the raw values rather than active record objects.What should we test?
I did a bit of benchmarking myself, but feel free to run these as well to compare:
where benchmark.rb is:
I'm not sure if ~80K order cycles would be a representative number for a production instance, but it seems like there is enough of a difference here for this to be useful?
Release notes
Changelog Category (reviewers may add a label for the release notes):
The title of the pull request will be included in the release notes.
Dependencies
Documentation updates