Skip to content

Commit bfab73a

Browse files
authored
Merge pull request #376 from plural/fix-cycle-release-dates
Fix card cycles release date calculation
2 parents 9476391 + cf39993 commit bfab73a

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/tasks/cards.rake

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,13 @@ namespace :cards do
381381

382382
def update_date_release_for_cycles
383383
CardCycle.all.find_each do |c|
384-
c.date_release = (c.card_sets.min_by { :date_release }).date_release
384+
num_non_booster_sets = c.card_sets.where.not(card_set_type_id: 'booster_pack').count
385+
386+
c.date_release = if num_non_booster_sets.positive?
387+
c.card_sets.where.not(card_set_type_id: 'booster_pack').minimum(:date_release)
388+
else
389+
c.card_sets.minimum(:date_release)
390+
end
385391
c.save
386392
end
387393
end

0 commit comments

Comments
 (0)