User status automation: add caching or work with timestamped user status to reduce number of calculations / calendar queries
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 36.9k
- Forks
- 5.2k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 713
Description
Feature Request
With https://github.com/nextcloud/server/issues/31177, the calculation for the user status will be redone any time the user status API endpoint is called, even if the availability hasn't changed at all.
This includes
- loading of all calendars
- querying of all calendars for events within the next hour
- the availability calculation
- updating the status if neccessary (db query)
As calendar queries are quite expensive, they shouldn't be redone any time the user status is called.
Implementation
There are two options on how to reduce the workload.
The first option is to cache all or some of the calculation by:
- Caching the complete FREEBUSY result
- Caching the VAVILABILITY settings (-1 query to the database)
- Not updating the status if a cache hit exists (-1 query to the database, plus no recalculation)
- Caching the query results for the calendar query
- Caching the search for calendars via principal URI
Using the status timestamp is another option to reduce the recalcualtation.
The user_status app already provides a timestamp when a status will become invalid. It would possible to use the end timestamp of a busy period from the FREEBUSY calculation to invalidate the status for a regular busy event.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the user status API endpoint and trace the calendar loading, FREEBUSY calculation, availability lookup, and status update described in the issue. Compare caching with using the status or busy-period end timestamp, then verify that repeated requests avoid unnecessary calendar queries and recalculation while status invalidation still works.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- backend, performance
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100