gitlab-org--gitlab-foss/app/models/project_daily_statistic.rb
Jacopo 5ae9a44aa1 Add project http fetch statistics API
The API get projects/:id/traffic/fetches allows user with write
access to the repository to get the number of clones for the
last 30 days.
2019-02-27 11:52:35 +01:00

10 lines
372 B
Ruby

# frozen_string_literal: true
class ProjectDailyStatistic < ActiveRecord::Base
belongs_to :project
scope :of_project, -> (project) { where(project: project) }
scope :of_last_30_days, -> { where('date >= ?', 29.days.ago.utc.to_date) }
scope :sorted_by_date_desc, -> { order(project_id: :desc, date: :desc) }
scope :sum_fetch_count, -> { sum(:fetch_count) }
end