Welcome to mirror list, hosted at ThFree Co, Russian Federation.

design_user_notes_count_service.rb « design_management « services « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e49914ea6d32650febde9b868ac167de10c2d77e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# frozen_string_literal: true

module DesignManagement
  # Service class for counting and caching the number of unresolved
  # notes of a Design
  class DesignUserNotesCountService < ::BaseCountService
    # The version of the cache format. This should be bumped whenever the
    # underlying logic changes. This removes the need for explicitly flushing
    # all caches.
    VERSION = 1

    def initialize(design)
      @design = design
    end

    def relation_for_count
      design.notes.user
    end

    def raw?
      # Since we're storing simple integers we don't need all of the
      # additional Marshal data Rails includes by default.
      true
    end

    def cache_key
      ['designs', 'notes_count', VERSION, design.id]
    end

    private

    attr_reader :design
  end
end