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 b43d065
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
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
24 changes: 22 additions & 2 deletions tests/test_plugins_entry_dedupe.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,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 +419,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 +459,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 +469,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 b43d065

Please sign in to comment.