diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-19 10:33:21 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-19 10:33:21 +0300 |
commit | 36a59d088eca61b834191dacea009677a96c052f (patch) | |
tree | e4f33972dab5d8ef79e3944a9f403035fceea43f /app/models/raw_usage_data.rb | |
parent | a1761f15ec2cae7c7f7bbda39a75494add0dfd6f (diff) |
Add latest changes from gitlab-org/gitlab@15-0-stable-eev15.0.0-rc42
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 |