Class: DesignManagement::DesignUserNotesCountService

Inherits:
BaseCountService show all
Defined in:
app/services/design_management/design_user_notes_count_service.rb

Overview

Service class for counting and caching the number of unresolved notes of a Design

Constant Summary collapse

VERSION =

The version of the cache format. This should be bumped whenever the underlying logic changes. This removes the need for explicitly flushing all caches.

1

Instance Method Summary collapse

Methods inherited from BaseCountService

#cache_options, #count, #count_stored?, #delete_cache, #refresh_cache, #uncached_count, #update_cache_for_key

Constructor Details

#initialize(design) ⇒ DesignUserNotesCountService

Returns a new instance of DesignUserNotesCountService.


12
13
14
# File 'app/services/design_management/design_user_notes_count_service.rb', line 12

def initialize(design)
  @design = design
end

Instance Method Details

#cache_keyObject


26
27
28
# File 'app/services/design_management/design_user_notes_count_service.rb', line 26

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

#raw?Boolean

Returns:

  • (Boolean)

20
21
22
23
24
# File 'app/services/design_management/design_user_notes_count_service.rb', line 20

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

#relation_for_countObject


16
17
18
# File 'app/services/design_management/design_user_notes_count_service.rb', line 16

def relation_for_count
  design.notes.user
end