Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PERF: removed N*2+1 in availability topic (#599)
WE "recently" did a few changes in the way we use the availability topic - We used to have 1 topic per year, but have now moved to just using one topic and deleted past posts - We used to delete past automatic holidays, but we don't anymore since we use them to keep track of #leave days used - There are more employees covering more regions All three changes made the query that list all the events to be displayed in the availability topic go 💥 It used to be - 1 query to list all events from 6 months ago up to 6 months in the future - 1 query for every events to load the associated user - 1 query for every events to load the associated's user timezone So basically, a N*2 + 1 😅 This commit fixes the issue by doing - 1 query to get all "standalone" events (those associated to a post) - 1 query to get all the users timezones (just the ones who have an holiday in the current period). - 1 query to get all the "automatic" events (aka. holidays that are comming from the holidays gem). So we went from N*2 + 1 down to 3 🚀
- Loading branch information