Skip to content

Commit

Permalink
Reword ThingyList.distinct code so that it makes more sense
Browse files Browse the repository at this point in the history
  • Loading branch information
ramnes committed Dec 14, 2022
1 parent 829c331 commit 7ff4839
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions mongo_thingy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@

class ThingyList(list):
def distinct(self, key):
def __get_value(document):
if hasattr(document, "__dict__"):
document = document.__dict__
return document.get(key)
def __get_value(item):
if isinstance(item, BaseThingy):
item = item.view()
return item.get(key)

values = set(__get_value(result) for result in self)
values = set(__get_value(item) for item in self)
return list(values)


Expand Down

0 comments on commit 7ff4839

Please sign in to comment.