From 7ab46bc48edc905d35c17c3960733e931d87123f Mon Sep 17 00:00:00 2001 From: Jon Michael Aanes Date: Mon, 26 Aug 2024 00:37:51 +0200 Subject: [PATCH] Improved title --- git_time_tracker/format/icalendar.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/git_time_tracker/format/icalendar.py b/git_time_tracker/format/icalendar.py index 27f7360..1731bdd 100644 --- a/git_time_tracker/format/icalendar.py +++ b/git_time_tracker/format/icalendar.py @@ -15,6 +15,18 @@ ZERO_DURATION = datetime.timedelta(seconds=0) HOUR = datetime.timedelta(hours=1) MINUTE = datetime.timedelta(minutes=1) + +def create_title(sample: RealizedWorkSample) -> str: + ls = [] + for label_and_type in sample.labels: + if label_and_type.startswith(HIDDEN_LABEL_PREFIX): + continue + if label_and_type.startswith('author:'): + continue + ls.append(label_and_type) + return ' '.join(ls) + + def generate_calendar( samples: list[RealizedWorkSample], ) -> icalendar.Calendar: @@ -26,7 +38,7 @@ def generate_calendar( for sample in samples: - title = ' '.join(sample.labels) + title = create_title(sample) description = '' @@ -38,6 +50,10 @@ def generate_calendar( event.add('dtstart', sample.start_at) event.add('dtend', sample.end_at) + for label_and_type in sample.labels: + if label_and_type.startswith('author:'): + event.add('organizer', 'mailto:'+label_and_type.removeprefix('author:')) + cal.add_component(event) del event