Skip to content
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

Make dev seeds independent on available locales #4733

Merged
merged 7 commits into from
Dec 14, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Simplify code in budget dev seeds
Now changing the code dealing with locales is going to be easier.
  • Loading branch information
javierm committed Dec 13, 2021
commit e9d7d2744d52b4571de386560616b65d5822e8e9
84 changes: 35 additions & 49 deletions db/dev_seeds/budgets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,67 +57,53 @@ def add_image_to(imageable)
end

Budget.all.each do |budget|
city_group_params = {
city_group = budget.groups.create!(
name_en: I18n.t("seeds.budgets.groups.all_city", locale: :en),
name_es: I18n.t("seeds.budgets.groups.all_city", locale: :es)
}
city_group = budget.groups.create!(city_group_params)
)

city_heading_params = {
city_group.headings.create!(
name_en: I18n.t("seeds.budgets.groups.all_city", locale: :en),
name_es: I18n.t("seeds.budgets.groups.all_city", locale: :es),
price: 1000000,
population: 1000000,
latitude: "40.416775",
longitude: "-3.703790"
}
city_group.headings.create!(city_heading_params)
)

districts_group_params = {
districts_group = budget.groups.create!(
name_en: I18n.t("seeds.budgets.groups.districts", locale: :en),
name_es: I18n.t("seeds.budgets.groups.districts", locale: :es)
}
districts_group = budget.groups.create!(districts_group_params)

north_heading_params = {
name_en: I18n.t("seeds.geozones.north_district", locale: :en),
name_es: I18n.t("seeds.geozones.north_district", locale: :es),
price: rand(5..10) * 100000,
population: 350000,
latitude: "40.416775",
longitude: "-3.703790"
}
districts_group.headings.create!(north_heading_params)

west_heading_params = {
name_en: I18n.t("seeds.geozones.west_district", locale: :en),
name_es: I18n.t("seeds.geozones.west_district", locale: :es),
price: rand(5..10) * 100000,
population: 300000,
latitude: "40.416775",
longitude: "-3.703790"
}
districts_group.headings.create!(west_heading_params)

east_heading_params = {
name_en: I18n.t("seeds.geozones.east_district", locale: :en),
name_es: I18n.t("seeds.geozones.east_district", locale: :es),
price: rand(5..10) * 100000,
population: 200000,
latitude: "40.416775",
longitude: "-3.703790"
}
districts_group.headings.create!(east_heading_params)

central_heading_params = {
name_en: I18n.t("seeds.geozones.central_district", locale: :en),
name_es: I18n.t("seeds.geozones.central_district", locale: :es),
price: rand(5..10) * 100000,
population: 150000,
latitude: "40.416775",
longitude: "-3.703790"
}
districts_group.headings.create!(central_heading_params)
)

[
{
name_en: I18n.t("seeds.geozones.north_district", locale: :en),
name_es: I18n.t("seeds.geozones.north_district", locale: :es),
population: 350000
},
{
name_en: I18n.t("seeds.geozones.west_district", locale: :en),
name_es: I18n.t("seeds.geozones.west_district", locale: :es),
population: 300000,
},
{
name_en: I18n.t("seeds.geozones.east_district", locale: :en),
name_es: I18n.t("seeds.geozones.east_district", locale: :es),
population: 200000,
},
{
name_en: I18n.t("seeds.geozones.central_district", locale: :en),
name_es: I18n.t("seeds.geozones.central_district", locale: :es),
population: 150000,
}
].each do |heading_params|
districts_group.headings.create!(heading_params.merge(
price: rand(5..10) * 100000,
latitude: "40.416775",
longitude: "-3.703790"
))
end
end
end

Expand Down