Skip to content

Commit

Permalink
Reduce unneeded and error-prone seedings
Browse files Browse the repository at this point in the history
  • Loading branch information
kronn committed Dec 18, 2024
1 parent 7a1d7a0 commit ecf9354
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions db/seeds/development/3_census.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2012-2018, Schweizer Blasmusikverband. This file is part of
# Copyright (c) 2012-2024, Schweizer Blasmusikverband. This file is part of
# hitobito_sbv and licensed under the Affero General Public License version 3
# or later. See the COPYING file at the top-level directory or at
# https://github.com/hitobito/hitobito_sbv.
Expand All @@ -22,7 +22,6 @@
end

current_census = SongCensus.current
songs = Song.all.shuffle.take(10)

SongCensus.all.each do |census|
Group::Verein.all.shuffle.take(10).each do |verein|
Expand All @@ -34,11 +33,11 @@
concert.regionalverband_id = verein.parent.id if verein.parent.is_a?(Group::Regionalverband)
concert.mitgliederverband_id = verein.parent.parent.id if verein.parent.try(:parent).is_a?(Group::Mitgliederverband)
concert.year = census.year
concert.editable = (census == current_census)
end
end
Concert.all.each do |concert|
songs.shuffle.take(10).each do |song|

Concert.where(song_census_id: census.id, verein_id: verein.id).all.each do |concert|
Song.all.shuffle.take(10).each do |song|
SongCount.seed_once(:concert_id, :song_id) do |count|
count.concert_id = concert.id
count.song_id = song.id
Expand All @@ -49,3 +48,5 @@
end
end
end

Concert.where.not(year: current_census).update_all(editable: false)

0 comments on commit ecf9354

Please sign in to comment.