Files
nairobi/db/dev_seeds/milestones.rb
Javi Martín 8b13daad95 Add and apply rules for multi-line hashes
For the HashAlignment rule, we're using the default `key` style (keys
are aligned and values aren't) instead of the `table` style (both keys
and values are aligned) because, even if we used both in the
application, we used the `key` style a lot more. Furthermore, the
`table` style looks strange in places where there are both very long and
very short keys and sometimes we weren't even consistent with the
`table` style, aligning some keys without aligning other keys.

Ideally we could align hashes to "either key or table", so developers
can decide whether keeping the symmetry of the code is worth it in a
case-per-case basis, but Rubocop doesn't allow this option.
2023-08-18 14:56:16 +02:00

46 lines
1.5 KiB
Ruby

section "Creating default Milestone Statuses" do
Milestone::Status.create!(name: I18n.t("seeds.budgets.statuses.studying_project"))
Milestone::Status.create!(name: I18n.t("seeds.budgets.statuses.bidding"))
Milestone::Status.create!(name: I18n.t("seeds.budgets.statuses.executing_project"))
Milestone::Status.create!(name: I18n.t("seeds.budgets.statuses.executed"))
end
section "Creating investment milestones" do
[Budget::Investment, Proposal, Legislation::Process].each do |model|
model.find_each do |record|
rand(1..5).times do
milestone = record.milestones.build(
publication_date: Date.tomorrow,
status_id: Milestone::Status.all.sample
)
random_locales.map do |locale|
Globalize.with_locale(locale) do
milestone.description = "Description for locale #{locale}"
milestone.title = I18n.l(Time.current, format: :datetime)
milestone.save!
end
end
end
if rand < 0.8
record.progress_bars.create!(kind: :primary, percentage: rand(ProgressBar::RANGE))
end
rand(0..3).times do
progress_bar = record.progress_bars.build(
kind: :secondary,
percentage: rand(ProgressBar::RANGE)
)
random_locales.map do |locale|
Globalize.with_locale(locale) do
progress_bar.title = "Description for locale #{locale}"
progress_bar.save!
end
end
end
end
end
end