From b8fff2291a27811663a0fae713cda5b3a18560c6 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 24 Jul 2017 10:42:37 -0700 Subject: [PATCH] Added a rake task for DEV so mock users can automatically adopt drains. I created this initially to test out how the API would handle load --- lib/tasks/data.rake | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/tasks/data.rake b/lib/tasks/data.rake index 556ed44d..051de804 100644 --- a/lib/tasks/data.rake +++ b/lib/tasks/data.rake @@ -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