diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ffa09d..b8de63e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,11 +7,15 @@ and this project does adhere to [Semantic Versioning](https://semver.org/spec/v2 ## [Unreleased] +### Fixed +- No duplicate `GroupBySource` entries in `vgroups` filter (while keeping sort order) + + ## [0.9.9] – 2022-12-21 ### Fixed -- Keep original sorting order in `vgroups` filter if no `order_by` is set. +- Keep original sorting order in `vgroups` filter if no `order_by` is set diff --git a/lektor_groupby/backref.py b/lektor_groupby/backref.py index 9686013..db0326b 100644 --- a/lektor_groupby/backref.py +++ b/lektor_groupby/backref.py @@ -1,5 +1,5 @@ from lektor.context import get_ctx -from typing import TYPE_CHECKING, Set, List, Union, Iterable, Iterator +from typing import TYPE_CHECKING, Set, Dict, Union, Iterable, Iterator import weakref from .util import split_strip if TYPE_CHECKING: @@ -68,7 +68,9 @@ class VGroups: GroupByRef.of(builder).make_once(keys) # ensure did cluster before use # find groups proc_list = [record] - done_list = [] # type: List[GroupBySource] + # Note: An ordered Set would be more approptiate but there is none. + # So lets use the insert order of dict (guaranteed since Python 3.7) + done_list = {} # type: Dict[GroupBySource, None] while proc_list: page = proc_list.pop(0) if recursive and hasattr(page, 'children'): @@ -80,7 +82,7 @@ class VGroups: continue if keys and vobj().config.key not in keys: continue - done_list.append(vobj()) + done_list[vobj()] = None # we only need the keys() # manage config dependencies deps = set() # type: Set[str]