diff --git a/Procfile b/Procfile index fa605c1a..394d20da 100644 --- a/Procfile +++ b/Procfile @@ -1,3 +1,3 @@ web: bundle exec puma -C config/puma.rb -release: bundle exec rails db:migrate && bundle exec rake projects:create_experience_cs_example +release: bundle exec rails db:migrate && bundle exec rake projects:create_experience_cs_examples worker: bundle exec good_job start --max-threads=8 diff --git a/lib/tasks/projects.rake b/lib/tasks/projects.rake index 4d95d781..33110619 100644 --- a/lib/tasks/projects.rake +++ b/lib/tasks/projects.rake @@ -6,21 +6,47 @@ namespace :projects do FilesystemProject.import_all! end - desc "Create example Scratch project for Experience CS (if it doesn't already exist)" - task create_experience_cs_example: :environment do - attributes = { - identifier: 'experience-cs-example', - locale: 'en', - project_type: Project::Types::SCRATCH, - name: 'Experience CS Example', - user_id: nil - } - if Project.unscoped.exists?(attributes.slice(:identifier, :locale)) - puts 'Scratch project already exists' - elsif Project.create(attributes) - puts 'Scratch project created successfully' - else - puts 'Scratch project creation failed' + desc "Create example Scratch projects for Experience CS (if they don't already exist)" + task create_experience_cs_examples: :environment do + projects = [ + { + identifier: 'experience-cs-example', + locale: 'en', + project_type: Project::Types::SCRATCH, + name: 'Experience CS Example', + user_id: nil + }, + { + identifier: 'dialogue-in-scratch', + locale: 'en', + project_type: Project::Types::SCRATCH, + name: 'Dialogue in Scratch', + user_id: nil + }, + { + identifier: 'ten-block-mission', + locale: 'en', + project_type: Project::Types::SCRATCH, + name: '10 Block Mission', + user_id: nil + }, + { + identifier: 'blank-scratch-starter', + locale: 'en', + project_type: Project::Types::SCRATCH, + name: 'Blank Scratch Starter', + user_id: nil + } + ] + projects.each do |attributes| + identifier = attributes[:identifier] + if Project.unscoped.exists?(attributes.slice(:identifier, :locale)) + puts "Scratch project with identifier '#{identifier}' already exists" + elsif Project.create(attributes) + puts "Scratch project with identifier '#{identifier}' created successfully" + else + puts "Scratch project with identifier '#{identifier}' creation failed" + end end end end