BE: Manually triggered user counts recalculation on self-managed instances
Currently Billable Users, Maximum Users, and Users over License values are calculated daily during an execution of a cron job. We need an API to manually trigger this recalculation when the user needs that. This is a backend counterpart of FE: Manually triggered user counts recalculatio... (#341118).
Mohamed @mhamda shared more details on possible approaches at #341118 (comment 1196394844)
The
Licensed users,Billable Users,Maximum Users, andUsers over Licensevalues are all coupled. If one value changes, the others might also change.
So, if I understand it right,
Licensed usersare encrypted into a licence, andMaximum UserswithUsers over Licenseare dynamically calculated based onBillable Users. Then looks like we just need to re-run the billable users calculation (as you initially suggested, @mhamda😊 ) and keep using that "updated at" in all cards. #341118 (comment 1198495023)
Based on the previous discussion, we need to only update Billable Users, since all other values are dynamically calculated based on it.
Changes Required:
- API for triggering the recalculation
- Triggering
CounterJobWorkerforBillable Usersasync in the API.
Availability & Testing
Depending on the final integration - test coverage for this feature addition could include API test for the endpoint (can be combined with the the recalculation tests if existing), feature test to trigger the recalculation from UI or update in an e2e test for such flow to manually trigger and expect the result.