3e561736b2
By caching the number of personal SSH keys we reduce the number of queries necessary on pages such as ProjectsController#show (which can end up querying this data multiple times). The cache is refreshed/flushed whenever an SSH key is added, removed, or when a user is removed.
13 lines
322 B
Ruby
13 lines
322 B
Ruby
module Projects
|
|
# Service class for counting and caching the number of open merge requests of
|
|
# a project.
|
|
class OpenMergeRequestsCountService < Projects::CountService
|
|
def relation_for_count
|
|
@project.merge_requests.opened
|
|
end
|
|
|
|
def cache_key_name
|
|
'open_merge_requests_count'
|
|
end
|
|
end
|
|
end
|