From 9bc4278c826a091a46b64062010723069dbc11a1 Mon Sep 17 00:00:00 2001 From: Stefan Bethke Date: Sat, 18 May 2024 21:05:00 +0200 Subject: [PATCH] use correct columns --- .forgejo/workflows/docker-image.yaml | 0 hedgedoc-expire.py | 7 +++++-- 2 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 .forgejo/workflows/docker-image.yaml diff --git a/.forgejo/workflows/docker-image.yaml b/.forgejo/workflows/docker-image.yaml new file mode 100644 index 0000000..e69de29 diff --git a/hedgedoc-expire.py b/hedgedoc-expire.py index f1e4bee..1527fad 100644 --- a/hedgedoc-expire.py +++ b/hedgedoc-expire.py @@ -90,6 +90,7 @@ def revisions_to_be_expired(cutoff: datetime) -> list[any]: """ revisions = [] with db.prepare('''SELECT + "Notes"."alias", "Revisions"."createdAt", "Users"."email", "Revisions"."id" as "revisionId", @@ -103,6 +104,7 @@ def revisions_to_be_expired(cutoff: datetime) -> list[any]: ''') as revs_older_than: for row in revs_older_than(cutoff): revisions.append({ + 'alias': row.alias, 'createdAt': row.createdAt, 'email': row.email, 'noteId': row.noteId, @@ -118,7 +120,8 @@ def check_notes_to_be_expired(age: timedelta, config: Config) -> None: print(f'Notes to be deleted older than {cutoff} ({humanize.naturaldelta(age)}):') for note in notes_to_be_expired(cutoff): age = datetime.now(timezone.utc) - datetime.fromisoformat(note['updatedAt']) - print(f' {note["email"]} ({humanize.naturaldelta(age)}) {config.url}/{note["alias"]}: {note["title"]}') + url = config.url + '/' + (note["alias"] if note["alias"] is not None else note["shortid"]) + print(f' {note["email"]} ({humanize.naturaldelta(age)}) {url}: {note["title"]}') def check_revisions_to_be_expired(age: timedelta, config: Config) -> None: @@ -132,7 +135,7 @@ def check_revisions_to_be_expired(age: timedelta, config: Config) -> None: notes[row['noteId']].append(row) for id, revisions in notes.items(): email = revisions[0]['email'] - url = config.url + '/' + (revisions[0]["title"] if revisions[0]["title"] is not None else revisions[0]["shorturl"]) + url = config.url + '/' + (revisions[0]["alias"] if revisions[0]["alias"] is not None else revisions[0]["shortid"]) print(f' {revisions[0]["email"]} {url}: {revisions[0]["title"]}') for rev in revisions: print(f' {humanize.naturaldelta(rev["age"])}: {rev["revisionId"]}')