debian-mirror-gitlab/app/services/projects/fetch_statistics_increment_service.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

28 lines
629 B
Ruby
Raw Normal View History

2019-07-07 11:18:12 +05:30
# frozen_string_literal: true
module Projects
class FetchStatisticsIncrementService
attr_reader :project
def initialize(project)
@project = project
end
def execute
increment_fetch_count_sql = <<~SQL
INSERT INTO #{table_name} (project_id, date, fetch_count)
VALUES (#{project.id}, '#{Date.today}', 1)
2019-10-12 21:52:04 +05:30
ON CONFLICT (project_id, date) DO UPDATE SET fetch_count = #{table_name}.fetch_count + 1
2019-07-07 11:18:12 +05:30
SQL
2021-10-27 15:23:28 +05:30
ProjectDailyStatistic.connection.execute(increment_fetch_count_sql)
2019-07-07 11:18:12 +05:30
end
private
def table_name
ProjectDailyStatistic.table_name
end
end
end