From dfa73cbee49c6df31d5b08982cce43cb0f81a760 Mon Sep 17 00:00:00 2001 From: Campbell Alden Date: Fri, 10 Feb 2023 15:41:27 +0900 Subject: [PATCH] Sort signoff output by modified date --- dump.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/dump.py b/dump.py index 77b25fa..90b743a 100644 --- a/dump.py +++ b/dump.py @@ -2,7 +2,7 @@ import things import argparse import re import random -import sys +from datetime import datetime with open('./emojis.txt', 'r') as emoji_file: EMOJIS = [l.strip() for l in emoji_file.readlines()] @@ -140,11 +140,14 @@ def generate_signoff_message(target_tag): structured_tasks = tasks_to_heirarchy({ 'title': 'Stopping now', 'notes': '', 'status': '' }, reportable) return format_tasks(structured_tasks, 0) +def by_modified_timestamp(val): + return datetime.fromisoformat(val['modified']) + def generate_today_message(target_tag): format_tasks = make_recursive_formatter(TodayFormatter()) reportable = list(filter(lambda t: has_tag(t, target_tag), things.today())) - for task in reportable: + for task in sorted(reportable, key=by_modified_timestamp): sanitize_mentions(task) top_level_comment = ' '.join(map(lambda e: f':{e}:', random.choices(EMOJIS, k=3)))