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

20161122203926_populate_user_contribution_table.rb « migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d2bd6f63c333ef97fae37ac65e3c8d26674afccf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.

class PopulateUserContributionTable < ActiveRecord::Migration
  include Gitlab::Database::MigrationHelpers

  DOWNTIME = false

  def up
    base_delay = Time.now + 15.minutes

    (Date.today - 1.year).upto(Date.today).each_with_index do |date, index|
      job_time = base_delay + index.minutes

      Sidekiq::Client.enqueue_to_in(:cronjob, job_time, UserContributionWorker, date)
    end
  end

  def down
    execute 'TRUNCATE user_contributions'
  end
end