From 0ff23013dcd9ec74e5a428de72fdbf8234723227 Mon Sep 17 00:00:00 2001 From: Cédric Bonhomme Date: Wed, 4 Mar 2020 14:09:56 +0100 Subject: Retrun the bookmarks saved during the last 365 days, starting from the date of the most recent one. --- newspipe/web/views/bookmark.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/newspipe/web/views/bookmark.py b/newspipe/web/views/bookmark.py index c7b4e623..071cf260 100644 --- a/newspipe/web/views/bookmark.py +++ b/newspipe/web/views/bookmark.py @@ -93,11 +93,16 @@ def list_(per_page, status="all"): else: # query for the shared bookmarks (of all users) head_titles = [gettext("Recent bookmarks")] - not_created_before = datetime.datetime.today() - datetime.timedelta(days=900) - filters["time__gt"] = not_created_before # only "recent" bookmarks filters["shared"] = True - - bookmarks = BookmarkController(user_id).read(**filters).order_by(desc("time")) + last_bookmark = ( + BookmarkController(user_id) + .read(**filters) + .order_by(desc("time")) + .limit(1)[0] + ) + not_created_before = last_bookmark.time - datetime.timedelta(days=365) + filters["time__gt"] = not_created_before # only "recent" bookmarks + bookmarks = BookmarkController(user_id).read(**filters).order_by(desc("time")) # tag_contr = BookmarkTagController(user_id) # tag_contr.read().join(bookmarks).all() -- cgit