Also find room for tracks in additional rooms
The get_track_room function failed to also look in additional rooms to find the room for a given track. If the event is not running in the current day, we should default to the first day of the event (useful for tests and the day before the event starts). Change-Id: I143eb3b490b3536679e0608064209ec71ed37499
This commit is contained in:
parent
d73d65a2c1
commit
d57f89dcb9
10
ptgbot/db.py
10
ptgbot/db.py
|
@ -15,6 +15,7 @@
|
|||
# limitations under the License.
|
||||
|
||||
import calendar
|
||||
from itertools import chain
|
||||
import json
|
||||
import os
|
||||
import datetime
|
||||
|
@ -73,9 +74,14 @@ class PTGDataBase():
|
|||
|
||||
def get_track_room(self, track):
|
||||
# This simplified version returns the first room the track is
|
||||
# scheduled in for the day
|
||||
# scheduled in for the day. If the event does not run on this
|
||||
# day, pick the first day.
|
||||
today = calendar.day_name[datetime.date.today().weekday()]
|
||||
for room, bookings in self.data['scheduled'].items():
|
||||
if today not in self.data['slots']:
|
||||
today = next(iter(self.data['slots']))
|
||||
all_schedule = chain(self.data['scheduled'].items(),
|
||||
self.data['additional'].items())
|
||||
for room, bookings in all_schedule:
|
||||
for btime, btrack in bookings.items():
|
||||
for slot in self.data['slots'].get(today, []):
|
||||
if btrack == track and btime == slot['name']:
|
||||
|
|
Loading…
Reference in New Issue