diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-05 21:08:40 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-05 21:08:40 +0300 |
commit | 0b789f95a35aa3e4b99ce12fc98bd3cce6555602 (patch) | |
tree | 886c728abbd90836e6846fcf4bb789be243c5253 /app/models/raw_usage_data.rb | |
parent | dad16033c2b7cfd54ffe20ca5cc1d844e9e41be6 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/raw_usage_data.rb')
-rw-r--r-- | app/models/raw_usage_data.rb | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/app/models/raw_usage_data.rb b/app/models/raw_usage_data.rb index 6fe3b26b58b..a6844eb8616 100644 --- a/app/models/raw_usage_data.rb +++ b/app/models/raw_usage_data.rb @@ -1,9 +1,16 @@ # frozen_string_literal: true class RawUsageData < ApplicationRecord + REPORTING_CADENCE = 7.days.freeze + validates :payload, presence: true validates :recorded_at, presence: true, uniqueness: true + scope :for_current_reporting_cycle, -> do + where('created_at >= ?', REPORTING_CADENCE.ago.beginning_of_day) + .order(created_at: :desc) + end + def update_version_metadata!(usage_data_id:) self.update_columns(sent_at: Time.current, version_usage_data_id_value: usage_data_id) end |