Skip to content

Commit

Permalink
Added a rake task for DEV so mock users can automatically adopt drain…
Browse files Browse the repository at this point in the history
…s. I created this initially to test out how the API would handle load
  • Loading branch information
root authored and root committed Jul 24, 2017
1 parent ceca853 commit b8fff22
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/tasks/data.rake
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,18 @@ namespace :data do

ThingImporter.load('https://data.sfgov.org/api/views/jtgq-b7c5/rows.csv?accessType=DOWNLOAD')
end

task auto_adopt: :environment do
# Make random users adopt drains to test server load when generating API data

if !Rails.env.production?
Thing.first(10_000).each do |t|
if t.user_id.blank?
t.user_id = User.find_by('id' => Random.rand(1..User.last.id)).id
t.save()
end
end
end

end
end

0 comments on commit b8fff22

Please sign in to comment.