optimize call of run_booking() + tests
This commit is contained in:
parent
95f06e8e26
commit
d800b17561
2 changed files with 38 additions and 21 deletions
17
planner.py
17
planner.py
|
@ -359,10 +359,12 @@ class ScheduledBooking(DeactivableMixin, ModelSQL, ModelView):
|
|||
super(ScheduledBooking, cls).write(*args)
|
||||
cls.update_next_occurence(records)
|
||||
|
||||
def run_booking(self):
|
||||
@classmethod
|
||||
def run_booking(cls, records):
|
||||
""" do prepared booking
|
||||
"""
|
||||
print('-- booking:', self.rec_name)
|
||||
for record in records:
|
||||
print('-- booking:', record.rec_name)
|
||||
|
||||
@classmethod
|
||||
def cronjob(cls):
|
||||
|
@ -376,11 +378,10 @@ class ScheduledBooking(DeactivableMixin, ModelSQL, ModelView):
|
|||
('active', '=', True),
|
||||
('nextrun.date', '<=', query_date)])
|
||||
|
||||
for record in records:
|
||||
record.run_booking()
|
||||
|
||||
cls.update_next_occurence(
|
||||
records,
|
||||
query_date=query_date + timedelta(days=1))
|
||||
if records:
|
||||
cls.run_booking(records)
|
||||
cls.update_next_occurence(
|
||||
records,
|
||||
query_date=query_date + timedelta(days=1))
|
||||
|
||||
# ens ScheduledBooking
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue