Skip to content

Commit

Permalink
Merge branch 'gh/couch/fix-cache' into autostaging
Browse files Browse the repository at this point in the history
  • Loading branch information
gherceg committed Oct 10, 2023
2 parents caf632b + 8e3a0d8 commit 9057b59
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 48 deletions.
49 changes: 5 additions & 44 deletions corehq/apps/cachehq/cachemodels.py
Original file line number Diff line number Diff line change
@@ -1,63 +1,24 @@
from dimagi.utils.couch.cache.cache_core import GenerationCache


class DomainGenerationCache(GenerationCache):
generation_key = '#gen#domain#'
doc_types = ['Domain']
views = [
"domain/snapshots",
"domain/published_snapshots",
"domain/not_snapshots",
"domain/copied_from_snapshot",
"domain/domains",
]


class UserGenerationCache(GenerationCache):
generation_key = '#gen#couch_user#'
doc_types = ['CommCareUser', 'CouchUser', 'WebUser']
views = [
"users/by_domain",
"users/phone_users_by_domain",
"users/by_default_phone",
"users/by_username",
"domain/old_users",
]


class GroupGenerationCache(GenerationCache):
generation_key = '#gen#group#'
doc_types = ['Group']
views = [
"groups/by_user",
"groups/by_name",
"groups/all_groups",
"users/by_group",
]


class UserRoleGenerationCache(GenerationCache):
generation_key = '#gen#user_role#'
doc_types = ['UserRole']
views = [
'users/roles_by_domain'
]


class ReportGenerationCache(GenerationCache):
generation_key = '#gen#reports#'
doc_types = ['ReportConfig', 'ReportNotification']
views = [
"reportconfig/all_notifications",
'reportconfig/configs_by_domain',
'reportconfig/notifications_by_config',
"reportconfig/user_notifications",
"reportconfig/daily_notifications",
]


class UserReportsDataSourceCache(GenerationCache):
generation_key = '#gen#userreports#datasource#'
doc_types = ['DataSourceConfiguration']
views = [
'userreports/active_data_sources',
'userreports/data_sources_by_build_info',
'userreports/data_sources_by_last_modified',
'userreports/report_configs_by_data_source',
'userreports/report_configs_by_domain',
]
4 changes: 0 additions & 4 deletions settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -1938,10 +1938,6 @@ def _pkce_required(client_id):
PILLOWTOPS[k] = plist

COUCH_CACHE_BACKENDS = [
'corehq.apps.cachehq.cachemodels.DomainGenerationCache',
'corehq.apps.cachehq.cachemodels.UserGenerationCache',
'corehq.apps.cachehq.cachemodels.GroupGenerationCache',
'corehq.apps.cachehq.cachemodels.UserRoleGenerationCache',
'corehq.apps.cachehq.cachemodels.ReportGenerationCache',
'corehq.apps.cachehq.cachemodels.UserReportsDataSourceCache',
'dimagi.utils.couch.cache.cache_core.gen.GlobalCache',
Expand Down

0 comments on commit 9057b59

Please sign in to comment.