Skip to content
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

Service usage cache and submissions suspended flag #5086

Merged
merged 33 commits into from
Oct 2, 2024

Conversation

Guitlle
Copy link
Contributor

@Guitlle Guitlle commented Aug 29, 2024

Description

This PR adds a reusable cache utility for classes to cache function getters. It is then used to cache the service usage calculator results. Some fields from the organization model are no longer needed due to this.

It also adds the submissions_suspended column to the user profile, instead of using the metadata JSON field.

Notes

The cached utility is at kpi.utils.cache, it is used by the ServiceUsageCalculator class. Note that for some tests, the cache has to be disabled, which can be done by patching the CachedClass methods. An example of this can be seen at kpi/tests/api/v2/test_api_service_usage.py

Related issues

Fixes TASK-1005
Fixes TASK-1003
Part of TASK-872

Copy link

Copy link

@Guitlle Guitlle force-pushed the task-1005-cache-service-usage branch from d0e8990 to 274a788 Compare August 30, 2024 22:59
@Guitlle Guitlle changed the base branch from beta-refactored to billing-addons-backend August 31, 2024 16:04
@Guitlle Guitlle changed the title Create cache for counters NLP Add ons Sep 3, 2024
Copy link

@Guitlle Guitlle force-pushed the task-1005-cache-service-usage branch from af2e952 to e25e1bf Compare September 3, 2024 14:27
@noliveleger noliveleger self-assigned this Sep 5, 2024
Copy link
Contributor

@noliveleger noliveleger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better if we could find a better PR title. It is not really obvious ;-)

kobo/apps/organizations/tests/test_organizations_api.py Outdated Show resolved Hide resolved
kobo/apps/organizations/tests/test_organizations_api.py Outdated Show resolved Hide resolved
kobo/apps/organizations/tests/test_organizations_api.py Outdated Show resolved Hide resolved
kobo/apps/project_ownership/tests/api/v2/test_api.py Outdated Show resolved Hide resolved
kobo/apps/organizations/tests/test_organizations_api.py Outdated Show resolved Hide resolved
kpi/tests/api/v2/test_api_service_usage.py Outdated Show resolved Hide resolved
kpi/utils/usage_calculator.py Outdated Show resolved Hide resolved
@Guitlle Guitlle changed the title NLP Add ons Service usage cache and submissions suspended flag Sep 10, 2024
kpi/utils/usage_calculator.py Show resolved Hide resolved
kpi/utils/cache.py Show resolved Hide resolved
kpi/deployment_backends/openrosa_backend.py Outdated Show resolved Hide resolved
Copy link
Contributor

@noliveleger noliveleger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM . Please leave a comment for InvalidCacheBackendError as requested and you can merge and close the PR.
Thank you.

@noliveleger
Copy link
Contributor

Oops, linter does not pass. Please address this before merging the PR ;)

Copy link

Task

1 similar comment
Copy link

Task

@noliveleger noliveleger merged commit 4318b55 into billing-addons-backend Oct 2, 2024
8 checks passed
@noliveleger noliveleger deleted the task-1005-cache-service-usage branch October 2, 2024 00:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants