Skip to content

Commit

Permalink
Fix entry_dedupe bug causing the flag of the newest entry to be set t…
Browse files Browse the repository at this point in the history
…o False, even if it was true before.

Found during to #140.
Likely introduced in #254.
  • Loading branch information
lemon24 committed Oct 11, 2021
1 parent a66a302 commit 89be7c0
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 5 deletions.
13 changes: 13 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,19 @@ Unreleased

* Support Python 3.10. (:issue:`248`)

* .. _yanked 2.2:

Fix :mod:`~reader.plugins.entry_dedupe` bug introduced in 2.2,
causing the newest read entry to be marked as unread
if none of its duplicates are read (idem for important).
This was an issue *only when re-running the plugin for existing entries*,
not for new entries (since new entries are unread and unimportant).
To ensure people don't use the buggy version,
*reader* 2.2 was `yanked`_ from PyPI.


.. _yanked: https://pypi.org/help/#yanked


Version 2.2
-----------
Expand Down
5 changes: 3 additions & 2 deletions src/reader/plugins/entry_dedupe.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,12 +348,13 @@ def by_title(e):


def _get_flag_args(entry, duplicates, name):
flag = any(getattr(d, name) for d in duplicates)
entries = duplicates + [entry]
flag = any(getattr(d, name) for d in entries)

modified_name = f'{name}_modified'
modifieds = (
getattr(e, modified_name)
for e in duplicates + [entry]
for e in entries
if getattr(e, name) == flag and getattr(e, modified_name)
)
modified = next(iter(sorted(modifieds)), None)
Expand Down
36 changes: 33 additions & 3 deletions tests/test_plugins_entry_dedupe.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ def test_plugin_once(make_reader, db_path, monkeypatch, tags):
(9, False, None),
],
),
# read, no modified
# old read, no modified
(
[
(1, True, None),
Expand All @@ -358,6 +358,16 @@ def test_plugin_once(make_reader, db_path, monkeypatch, tags):
(9, True, None),
],
),
# new read, no modified
(
[
(1, False, None),
(9, True, None),
],
[
(9, True, None),
],
),
# all read, earliest modified of the read entries is used (last has modified)
(
[
Expand Down Expand Up @@ -409,7 +419,7 @@ def test_read_modified_copying(make_reader, db_path, data, expected, same_last_u
(9, False, None),
],
),
# important, no modified
# old important, no modified
(
[
(1, True, None),
Expand All @@ -419,6 +429,16 @@ def test_read_modified_copying(make_reader, db_path, data, expected, same_last_u
(9, True, None),
],
),
# new important, no modified
(
[
(1, False, None),
(9, True, None),
],
[
(9, True, None),
],
),
# none important, modified
(
[
Expand Down Expand Up @@ -449,7 +469,7 @@ def test_read_modified_copying(make_reader, db_path, data, expected, same_last_u
(9, False, datetime(2010, 1, 1)),
],
),
# important, modified
# old important, modified
(
[
(1, True, datetime(2010, 1, 1)),
Expand All @@ -459,6 +479,16 @@ def test_read_modified_copying(make_reader, db_path, data, expected, same_last_u
(9, True, datetime(2010, 1, 1)),
],
),
# new important, old modified
(
[
(1, False, datetime(2010, 1, 1)),
(9, True, None),
],
[
(9, True, None),
],
),
]


Expand Down

0 comments on commit 89be7c0

Please sign in to comment.