Skip to content
This repository was archived by the owner on Jul 23, 2024. It is now read-only.

Commit acda972

Browse files
committed
Explicitly set parity or weeks to nil if weeks is specified or not
It seems that when it's not explicitly set, it's ignored when updating an existing record.
1 parent 36a19c8 commit acda972

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

app/interactors/convert_tts.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,15 @@ def build_rooms_hash(rooms)
3232
def convert_slot(slot, parallel_id)
3333
room_code = slot.room.link_id if slot.room
3434
slot_hash = slot.to_hash.select { |key, _| DB_KEYS.include? key }
35+
weeks = parse_weeks(slot.weeks)
3536

3637
TimetableSlot.new(slot_hash) do |s|
3738
s.id = slot.id
38-
s.parity = slot.parity if slot.weeks.blank?
39+
s.parity = weeks ? nil : slot.parity
3940
s.parallel_id = parallel_id
4041
s.room = @rooms[room_code] if room_code
4142
s.deleted_at = nil
42-
s.weeks = parse_weeks(slot.weeks) unless slot.weeks.blank?
43+
s.weeks = weeks
4344
end
4445
end
4546

@@ -50,6 +51,8 @@ def valid?(slot)
5051
end
5152

5253
def parse_weeks(weeks)
54+
return if weeks.blank?
55+
5356
weeks.split(',').flat_map { |interval|
5457
if interval.include?('-')
5558
from, to = interval.split('-', 2)

0 commit comments

Comments
 (0)