Class: Webhookdb::Tasks::Fixture

Inherits:
Rake::TaskLib
  • Object
show all
Defined in:
lib/webhookdb/tasks/fixture.rb

Instance Method Summary collapse

Constructor Details

#initializeFixture

Returns a new instance of Fixture.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/webhookdb/tasks/fixture.rb', line 10

def initialize
  super()
  namespace :fixture do
    desc "Create a bunch of fake integrations and fill them with data."
    task :full do
      require "webhookdb"
      Webhookdb.load_app
      require "webhookdb/fixtures"
      Webhookdb::Fixtures.load_all
      org = Webhookdb::Fixtures.organization.create
      org.prepare_database_connections?
      sints = Array.new(3) { Webhookdb::Fixtures.service_integration(organization: org).create }
      now = Time.now
      sints.each do |sint|
        svc = sint.replicator
        svc.create_table
        Array.new(5000) do |i|
          svc.upsert_webhook_body({"my_id" => i.to_s, "at" => (now - i.seconds).iso8601})
        end
      end
      puts "Created Webhookdb::Organization[#{org.id}]"
    end
  end
end