Skip to content

Make some endpoints up to x3 faster

Carlos Vega requested to merge fix/slow_api_points into master

These changes group operations to reduce the number of queries done to the DB and improve speed. In particular, the holiday timestamps are now retrieved for all workers instead of worker per worker. These are stored in a dictionary that serves as a map to provide the results for each worker at its due time to the remove_holidays function. Similarly, prepare worker availabilities obtains all the weekday availabilities of the given workers list. Previously this was done one by one for each worker. Code was adapted to these changes in both /api_views/worker.py and /api_views/daily_planning.py The expected speed up for the endpoint daily_planning/workers/availabilities is 3x

The same has been done for make the endpoints /api/appointments/GENERIC and /api/appointments/APPROACHING use less queries, and hence, faster

Before:

Screenshot_2024-05-17_at_16.19.24

After:

Screenshot_2024-05-17_at_16.19.55

Merge request reports