forked from DMPRoadmap/roadmap
-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Possible Unwanted Outcome From rake export_production_data:seed_5_export
#699
Comments
Here is the full rake task: # seed5: export all plan which org belongs to testers, this task generate the seed file that runs lastly
desc 'Export plan content from 3.0.2 database to seeds_5.rb'
task seed_5_export: :environment do
file_name = 'db/seeds/sandbox/seeds_5.rb'
FileUtils.rm_f(file_name)
excluded_keys = %w[created_at updated_at start_date end_date]
org_list = [Rails.application.secrets.funder_org_id.to_i, Rails.application.secrets.english_org_id.to_i,
Rails.application.secrets.french_org_id.to_i]
File.open(file_name, 'a') do |f|
Plan.where(org_id: org_list).all.each_with_index do |plan, index|
plan.title = "Test Plan #{index}"
plan.description = Faker::Lorem.sentence
# force a few plan to use modified template from the two test organizations for statistics
if [20..50].include?(index)
plan.template = Template.find(title: 'Portage Template-Test1')
elsif [60..90].include?(index)
plan.template = Template.find(title: 'Portage Template-Test2')
end
serialized = plan.serializable_hash.delete_if { |key, _value| excluded_keys.include?(key) }
f.puts "Plan.create(#{serialized})"
# import related roles
Role.where(plan_id: plan.id).all.each do |role|
role.user_id = if plan.org_id == Rails.application.secrets.funder_org_id.to_i # change all user id to 1
1
elsif plan.org_id == Rails.application.secrets.english_org_id.to_i # change all user id to 2
2
else # change all user id to 3
3
end
serialized = role.serializable_hash.delete_if { |key, _value| excluded_keys.include?(key) }
f.puts "Role.create(#{serialized})"
end
end
end
end
end |
aaronskiba
added a commit
that referenced
this issue
Mar 22, 2024
app/controllers/plan_exports_controller.rb - Line 125 was removed because it was essentially just a duplicate of line 127 (line 127 was added during commit 54ba0ad) lib/tasks/export_portage.rake - Added `rubocop:disable` to ignore these offences. However, the following GitHub issue has been created to further investigate the effects of these offences on their associated rake task. #699
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Please complete the following fields as applicable:
What version of the DMPRoadmap code are you running? (e.g. v2.2.0)
4.0.2+portage-4.0.1
Description
v4.1.0
upgrade, I encountered the following rubocop offenses:Here is the corresponding code in
lib/tasks/export_portage.rake
:The issue is that
if [20..50].include?(index)
andelsif [60..90].include?(index)
will always be false:We will have to examine the consequences of this.
The text was updated successfully, but these errors were encountered: