use correct columns

This commit is contained in:
Stefan Bethke 2024-05-18 21:05:00 +02:00
parent 7c4cb94ea8
commit 9bc4278c82
2 changed files with 5 additions and 2 deletions

View file

View file

@ -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"]}')