diff options
author | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2020-03-04 14:09:56 +0100 |
---|---|---|
committer | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2020-03-04 14:09:56 +0100 |
commit | 0ff23013dcd9ec74e5a428de72fdbf8234723227 (patch) | |
tree | b5d112755cea993b767d1f5c7d197fe6350e0f77 | |
parent | Improved bookmarks template. (diff) | |
download | newspipe-0ff23013dcd9ec74e5a428de72fdbf8234723227.tar.gz newspipe-0ff23013dcd9ec74e5a428de72fdbf8234723227.tar.bz2 newspipe-0ff23013dcd9ec74e5a428de72fdbf8234723227.zip |
Retrun the bookmarks saved during the last 365 days, starting from the date of the most recent one.
-rw-r--r-- | newspipe/web/views/bookmark.py | 13 |
1 files 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() |