Skip to content

Commit f68a9e2

Browse files
floehoppersebjacobs
andcommitted
Allow multiple Experience CS example projects
This renames the `projects:create_experience_cs_example` rake task to `projects:create_experience_cs_examples` and iterates over an array to (potentially) add multiple projects. For now there's still only one project being created, but we plan to add another in a subsequent commit. Co-authored-by: Seb Jacobs <[email protected]>
1 parent afaf756 commit f68a9e2

File tree

2 files changed

+20
-16
lines changed

2 files changed

+20
-16
lines changed

Procfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
web: bundle exec puma -C config/puma.rb
2-
release: bundle exec rails db:migrate && bundle exec rake projects:create_experience_cs_example
2+
release: bundle exec rails db:migrate && bundle exec rake projects:create_experience_cs_examples
33
worker: bundle exec good_job start --max-threads=8

lib/tasks/projects.rake

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,25 @@ namespace :projects do
66
FilesystemProject.import_all!
77
end
88

9-
desc "Create example Scratch project for Experience CS (if it doesn't already exist)"
10-
task create_experience_cs_example: :environment do
11-
attributes = {
12-
identifier: 'experience-cs-example',
13-
locale: 'en',
14-
project_type: Project::Types::SCRATCH,
15-
name: 'Experience CS Example',
16-
user_id: nil
17-
}
18-
if Project.unscoped.exists?(attributes.slice(:identifier, :locale))
19-
puts 'Scratch project already exists'
20-
elsif Project.create(attributes)
21-
puts 'Scratch project created successfully'
22-
else
23-
puts 'Scratch project creation failed'
9+
desc "Create example Scratch projects for Experience CS (if they don't already exist)"
10+
task create_experience_cs_examples: :environment do
11+
projects = [
12+
{
13+
identifier: 'experience-cs-example',
14+
locale: 'en',
15+
project_type: Project::Types::SCRATCH,
16+
name: 'Experience CS Example',
17+
user_id: nil
18+
}
19+
]
20+
projects.each do |attributes|
21+
if Project.unscoped.exists?(attributes.slice(:identifier, :locale))
22+
puts 'Scratch project already exists'
23+
elsif Project.create(attributes)
24+
puts 'Scratch project created successfully'
25+
else
26+
puts 'Scratch project creation failed'
27+
end
2428
end
2529
end
2630
end

0 commit comments

Comments
 (0)