Class: Snippets::UpdateStatisticsService
- Inherits:
-
Object
- Object
- Snippets::UpdateStatisticsService
- Defined in:
- app/services/snippets/update_statistics_service.rb
Constant Summary collapse
- REPOSITORY_NOT_FOUND =
:repository_not_found
Instance Attribute Summary collapse
-
#snippet ⇒ Object
readonly
Returns the value of attribute snippet.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(snippet) ⇒ UpdateStatisticsService
constructor
A new instance of UpdateStatisticsService.
Constructor Details
#initialize(snippet) ⇒ UpdateStatisticsService
Returns a new instance of UpdateStatisticsService.
9 10 11 |
# File 'app/services/snippets/update_statistics_service.rb', line 9 def initialize(snippet) @snippet = snippet end |
Instance Attribute Details
#snippet ⇒ Object (readonly)
Returns the value of attribute snippet.
7 8 9 |
# File 'app/services/snippets/update_statistics_service.rb', line 7 def snippet @snippet end |
Instance Method Details
#execute ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/services/snippets/update_statistics_service.rb', line 13 def execute unless snippet.repository_exists? return ServiceResponse.error( message: 'Invalid snippet repository', reason: REPOSITORY_NOT_FOUND ) end snippet.repository.expire_statistics_caches statistics.refresh! ServiceResponse.success(message: 'Snippet statistics successfully updated.') end |