Skip to content

Commit

Permalink
Add script to generate cron schedule from fixtures data
Browse files Browse the repository at this point in the history
  • Loading branch information
vaastav committed Dec 20, 2019
1 parent 6c080dd commit c2f98ca
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions schedule.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from getters import get_fixtures_data
from dateutil.parser import parse
from datetime import timedelta

def generate_schedule():
fixtures = get_fixtures_data()
gw_dict = {}
for f in fixtures:
gw = f['event']
time = f['kickoff_time']
if gw is None:
continue
if gw not in gw_dict:
gw_dict[gw] = [time]
else:
gw_dict[gw] += [time]

sched_dates = []
for k,dates in gw_dict.items():
dates = [parse(d) for d in dates]
dates.sort(reverse=True)
run_date = dates[0] + timedelta(hours=12)
sched_dates += [run_date]

for run_date in sorted(sched_dates):
print(run_date.strftime("%M %H %d %m *"))

def main():
generate_schedule()

if __name__ == '__main__':
main()

1 comment on commit c2f98ca

@ravgeetdhillon
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool man. This is the right schedule. The schedule I use in my AI is to notify me about the best transfers for the next gameweek. That's why it runs 4 hours before the deadline.

Please sign in to comment.