Skip to content

Instantly share code, notes, and snippets.

@shawndeprey
Last active August 9, 2018 16:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shawndeprey/0b91ef39059b1d2f5c8fafc83891ff19 to your computer and use it in GitHub Desktop.
Save shawndeprey/0b91ef39059b1d2f5c8fafc83891ff19 to your computer and use it in GitHub Desktop.
# Create your open submission project with at least 3 briefs, save 5 applications and then run the following.
project_id = Project.last.id
@p = Project.find_by_id(project_id)
@stages = [
Stage.new({name: "Stage One", project_id: project_id, start_date: 3.weeks.ago, end_date: 2.weeks.ago, is_weighted: false, hide_other_activity: false}),
Stage.new({name: "Stage Two", project_id: project_id, start_date: 2.weeks.ago, end_date: 1.weeks.ago, is_weighted: true, hide_other_activity: true}),
Stage.new({name: "Stage Three", project_id: project_id, start_date: 1.weeks.ago, end_date: 1.hour.ago, is_weighted: false, hide_other_activity: false})
]
@stages.each{|s| s.save}
# When testing the score each brief run this part of the script
@p.project_open_submission.update_attributes({score_each_brief: false})
@brief_stages = []
@stages.each do |s|
@p.briefs.each do |b|
@brief_stages << BriefStage.new({brief_id: b.id, stage_id: s.id, is_weighted: [true, false].sample})
end
end
@brief_stages.each{|s| s.save}
# Create Application Funnel Relations for stages and brief_stages
@p.applications.each do |app|
ApplicationFunnelRelation.new({stage_id: @stages[0].id, application_id: app.id}).save
ApplicationFunnelRelation.new({stage_id: @stages[1].id, application_id: app.id}).save
ApplicationFunnelRelation.new({stage_id: @stages[2].id, application_id: app.id}).save
end
@brief_stages.each do |brief_stage|
ApplicationFunnelRelation.new({brief_stage_id: brief_stage.id, application_id: @p.applications[0].id}).save
ApplicationFunnelRelation.new({brief_stage_id: brief_stage.id, application_id: @p.applications[1].id}).save
ApplicationFunnelRelation.new({brief_stage_id: brief_stage.id, application_id: @p.applications[2].id}).save
ApplicationFunnelRelation.new({brief_stage_id: brief_stage.id, application_id: @p.applications[3].id}).save
ApplicationFunnelRelation.new({brief_stage_id: brief_stage.id, application_id: @p.applications[4].id}).save
end
# Create Criteria for stages and brief stages
@stages.each do |stage|
if stage.is_weighted
Criteria.new({name: "Market", project_id: @p.id, stage_id: stage.id, weight: 10}).save
Criteria.new({name: "Team", project_id: @p.id, stage_id: stage.id, weight: 10}).save
Criteria.new({name: "Product", project_id: @p.id, stage_id: stage.id, weight: 40}).save
Criteria.new({name: "Competition", project_id: @p.id, stage_id: stage.id, weight: 10}).save
Criteria.new({name: "Innovation", project_id: @p.id, stage_id: stage.id, weight: 30}).save
else
Criteria.new({name: "Market", project_id: @p.id, stage_id: stage.id}).save
Criteria.new({name: "Team", project_id: @p.id, stage_id: stage.id}).save
Criteria.new({name: "Product", project_id: @p.id, stage_id: stage.id}).save
Criteria.new({name: "Competition", project_id: @p.id, stage_id: stage.id}).save
Criteria.new({name: "Innovation", project_id: @p.id, stage_id: stage.id}).save
end
end
@brief_stages.each do |brief_stage|
if brief_stage.is_weighted
Criteria.new({name: "Market", project_id: @p.id, brief_stage_id: brief_stage.id, weight: 10}).save
Criteria.new({name: "Team", project_id: @p.id, brief_stage_id: brief_stage.id, weight: 10}).save
Criteria.new({name: "Product", project_id: @p.id, brief_stage_id: brief_stage.id, weight: 40}).save
Criteria.new({name: "Competition", project_id: @p.id, brief_stage_id: brief_stage.id, weight: 10}).save
Criteria.new({name: "Innovation", project_id: @p.id, brief_stage_id: brief_stage.id, weight: 30}).save
else
Criteria.new({name: "Market", project_id: @p.id, brief_stage_id: brief_stage.id}).save
Criteria.new({name: "Team", project_id: @p.id, brief_stage_id: brief_stage.id}).save
Criteria.new({name: "Product", project_id: @p.id, brief_stage_id: brief_stage.id}).save
Criteria.new({name: "Competition", project_id: @p.id, brief_stage_id: brief_stage.id}).save
Criteria.new({name: "Innovation", project_id: @p.id, brief_stage_id: brief_stage.id}).save
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment