Class: Projects::FetchStatisticsIncrementService
- Inherits:
-
Object
- Object
- Projects::FetchStatisticsIncrementService
- Defined in:
- app/services/projects/fetch_statistics_increment_service.rb
Instance Attribute Summary collapse
-
#project ⇒ Object
readonly
Returns the value of attribute project.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(project) ⇒ FetchStatisticsIncrementService
constructor
A new instance of FetchStatisticsIncrementService.
Constructor Details
#initialize(project) ⇒ FetchStatisticsIncrementService
Returns a new instance of FetchStatisticsIncrementService.
7 8 9 |
# File 'app/services/projects/fetch_statistics_increment_service.rb', line 7 def initialize(project) @project = project end |
Instance Attribute Details
#project ⇒ Object (readonly)
Returns the value of attribute project.
5 6 7 |
# File 'app/services/projects/fetch_statistics_increment_service.rb', line 5 def project @project end |
Instance Method Details
#execute ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'app/services/projects/fetch_statistics_increment_service.rb', line 11 def execute increment_fetch_count_sql = <<~SQL INSERT INTO #{table_name} (project_id, date, fetch_count) VALUES (#{project.id}, '#{Date.today}', 1) ON CONFLICT (project_id, date) DO UPDATE SET fetch_count = #{table_name}.fetch_count + 1 SQL ProjectDailyStatistic.connection.execute(increment_fetch_count_sql) end |