@@ -63,7 +63,7 @@ def compute_wizards_slots(pycamp):
6363 (slot_start , slot_end )
6464 )
6565 current_period = slot_end
66- print ( len ( slots ), slots )
66+
6767 slots = clean_wizards_free_slots (pycamp , slots )
6868
6969 return slots
@@ -197,21 +197,21 @@ def persist_wizards_schedule_in_db(pycamp):
197197async def schedule_wizards (update , context ):
198198 _ , pycamp = get_active_pycamp ()
199199
200- persist_wizards_schedule_in_db (pycamp )
200+ n = pycamp .clear_wizards_schedule ()
201+ logger .info ("Deleted wizards schedule ({} records)" .format (n ))
201202
202- notify_schedule_to_wizards ( update , context , pycamp )
203+ persist_wizards_schedule_in_db ( pycamp )
203204
205+ await notify_schedule_to_wizards (update , context , pycamp )
204206
205- async def show_wizards_schedule (update , context ):
206- _ , pycamp = get_active_pycamp ()
207207
208- agenda = WizardAtPycamp . select (). where ( pycamp == pycamp ). order_by ( WizardAtPycamp . init )
208+ def format_wizards_schedule ( agenda ):
209209 per_day = defaultdict (list )
210210 for entry in agenda :
211211 k = entry .init .strftime ("%a %d de %b" )
212212 per_day [k ].append (entry )
213213
214- msg = "Esta es la agenda de magos para el PyCamp {}" . format ( pycamp . headquarters )
214+ msg = "Agenda de magos:"
215215 for day , items in per_day .items ():
216216 msg += "\n El día _{}_:\n " .format (day )
217217 for i in items :
@@ -220,7 +220,13 @@ async def show_wizards_schedule(update, context):
220220 i .end .strftime ("%H:%M" ),
221221 "@" + i .wizard .username
222222 )
223-
223+ return msg
224+
225+ async def show_wizards_schedule (update , context ):
226+ _ , pycamp = get_active_pycamp ()
227+
228+ agenda = WizardAtPycamp .select ().where (pycamp == pycamp ).order_by (WizardAtPycamp .init )
229+ msg = format_wizards_schedule (agenda )
224230 logger .debug (msg )
225231
226232 await context .bot .send_message (
0 commit comments