fix(bot): 🐛 Servers leaderboard now updating.
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
from typing import Callable, Iterable, TypeVar
|
||||
|
||||
|
||||
T = TypeVar("T")
|
||||
U = TypeVar("U")
|
||||
|
||||
|
||||
def deduplicate(iter: Iterable[T], key: Callable[[T], U] = lambda i: i) -> list[T]:
|
||||
"""Deduplicates an Iterable.
|
||||
|
||||
Args:
|
||||
iter (Iterable[T]): The iterable with items to deduplicate.
|
||||
key (Callable[[T], U], optional): The key by which to deduplicate. Defaults to `lambda i: i`.
|
||||
|
||||
Returns:
|
||||
list[T]: A list with the deduplicated items.
|
||||
"""
|
||||
|
||||
found_keys = set()
|
||||
|
||||
result = []
|
||||
|
||||
for i in iter:
|
||||
if key(i) not in found_keys:
|
||||
result.append(i)
|
||||
|
||||
return result
|
||||
Reference in New Issue
Block a user