Class: Snippets::UpdateStatisticsService
- Inherits:
-
Object
- Object
- Snippets::UpdateStatisticsService
- Defined in:
- app/services/snippets/update_statistics_service.rb
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.
7 8 9 |
# File 'app/services/snippets/update_statistics_service.rb', line 7 def initialize(snippet) @snippet = snippet end |
Instance Attribute Details
#snippet ⇒ Object (readonly)
Returns the value of attribute snippet.
5 6 7 |
# File 'app/services/snippets/update_statistics_service.rb', line 5 def snippet @snippet end |
Instance Method Details
#execute ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'app/services/snippets/update_statistics_service.rb', line 11 def execute unless snippet.repository_exists? return ServiceResponse.error(message: 'Invalid snippet repository', http_status: 400) end snippet.repository.expire_statistics_caches statistics.refresh! ServiceResponse.success(message: 'Snippet statistics successfully updated.') end |