Rename Demo project and create rake task to create it on existing users

Closes SCI-3080.
This commit is contained in:
Jure Grabnar 2019-02-21 23:31:55 +01:00
parent 7b6c6c414d
commit ffe0493013
2 changed files with 15 additions and 3 deletions

View file

@ -152,8 +152,8 @@ module FirstTimeDataGenerator
) )
end end
name = 'Demo project - qPCR' name = 'Demo project'
exp_name = 'Polymerase chain reaction' exp_name = 'qPCR Experiment Version 01'
# If there is an existing demo project, archive and rename it # If there is an existing demo project, archive and rename it
if team.projects.where(name: name).present? if team.projects.where(name: name).present?
# TODO: check if we still need this code # TODO: check if we still need this code
@ -161,7 +161,7 @@ module FirstTimeDataGenerator
# old.archive! user # old.archive! user
i = 1 i = 1
while team.projects.where( while team.projects.where(
name: name = "Demo project - qPCR (#{i})" name: name = "#{name} (#{i})"
).present? ).present?
i += 1 i += 1
end end

View file

@ -138,4 +138,16 @@ namespace :data do
"Templates, total number of updated projects: #{updated} out of #{total}}" "Templates, total number of updated projects: #{updated} out of #{total}}"
) )
end end
desc 'Create demo project on existing users'
task create_demo_project_on_existing_users: :environment do
require "#{Rails.root}/app/utilities/first_time_data_generator"
include FirstTimeDataGenerator
Rails.logger.info('Creating demo project on existing users')
User.find_each do |user|
seed_demo_data(user, user.teams.first)
end
end
end end