Welcome to mirror list, hosted at ThFree Co, Russian Federation.

29_instance_statistics.rb « development « fixtures « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c4af13d0f4df91595c3a52e6d66fc32580dd767d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# frozen_string_literal: true

require './spec/support/sidekiq_middleware'

Gitlab::Seeder.quiet do
  model_class = Analytics::InstanceStatistics::Measurement
  recorded_at = Date.today

  # Insert random counts for the last 10 weeks
  measurements = 10.times.flat_map do
    recorded_at = (recorded_at - 1.week).end_of_week.end_of_day - 5.minutes

    model_class.identifiers.map do |_, id|
      {
        recorded_at: recorded_at,
        count: rand(1_000_000),
        identifier: id
      }
    end
  end

  model_class.upsert_all(measurements, unique_by: [:identifier, :recorded_at])

  print '.'
end