Skip to content

Commit

Permalink
Merge pull request #3575 from szarnyasg/release-cal
Browse files Browse the repository at this point in the history
Filter old releases from future releases in release calendar
  • Loading branch information
szarnyasg authored Sep 9, 2024
2 parents 44ac538 + 3ea0e8a commit e880b89
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion scripts/get_calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,19 @@
import requests
from icalendar import Calendar
from datetime import datetime, timedelta
import duckdb
import json
import re

# URL of the .ics file
ics_url = "https://calendar.google.com/calendar/ical/c_rqj60henfnuin5klbati6g9kfg%40group.calendar.google.com/public/basic.ics"

# Get old releases
old_versions = duckdb.sql(
"SELECT version_number FROM '_data/past_releases.csv';"
).fetchall()
old_versions = [v[0] for v in old_versions]

# Download .ics file
response = requests.get(ics_url)
if response.status_code == 200:
Expand All @@ -17,6 +25,16 @@
upcoming_events = []
for event in cal.walk():
dtstart = event.get("DTSTART")
title = event.get("SUMMARY")
if title is None:
continue

version_search = re.search("([0-9]+\\.[0-9]+\\.[0-9])", title)
if version_search:
upcoming_version = version_search.group(1)
if upcoming_version in old_versions:
continue

if dtstart is not None and hasattr(dtstart, "dt"):
dtstart_date = dtstart.dt
if isinstance(dtstart_date, datetime):
Expand All @@ -25,7 +43,7 @@
end_date = event.get("DTEND")
upcoming_events.append(
{
"title": event.get("SUMMARY"),
"title": title,
"start_date": (
dtstart_date.isoformat()
if hasattr(dtstart_date, "isoformat")
Expand Down

0 comments on commit e880b89

Please sign in to comment.