Skip to content

Commit

Permalink
rate limit
Browse files Browse the repository at this point in the history
  • Loading branch information
ashleyzhang01 committed Mar 6, 2024
1 parent c7cd33d commit 0860326
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions backend/penndata/management/commands/get_penn_today_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ def handle(self, *args, **kwargs):
else:
start_time = datetime.datetime.strptime(start_time_str, "%I:%M%p").time()
start_date = datetime.datetime.combine(start_date, start_time)

if start_date > now + datetime.timedelta(days=31):
continue

event_url = urljoin(PENN_TODAY_WEBSITE, article.find("a", class_="tease__link")["href"])

Expand Down Expand Up @@ -97,7 +100,7 @@ def handle(self, *args, **kwargs):
Event.objects.update_or_create(
name=name,
defaults={
"event_type": "",
"event_type": "Penn Today",
"image_url": "",
"start": timezone.make_aware(start_date),
"end": timezone.make_aware(end_date),
Expand All @@ -108,7 +111,7 @@ def handle(self, *args, **kwargs):
},
)

self.stdout.write("Uploaded Events!")
self.stdout.write("Uploaded Penn Today Events!")

def connect_and_parse_html(self, event_url, condition):
try:
Expand Down

0 comments on commit 0860326

Please sign in to comment.