twitter: use created_at as an extra key for merging

This commit is contained in:
Dima Gerasimov 2022-05-30 19:53:35 +01:00 committed by karlicoss
parent 4104f821fa
commit 44a6b17ec3

View file

@ -18,9 +18,13 @@ def merge_tweets(*sources: Iterator[Res[Tweet]]) -> Iterator[Res[Tweet]]:
if isinstance(r, Exception):
return str(r)
else:
return r.id_str
# using both fields as key makes it a bit easier to spot TZ issues
return (r.id_str, r.created_at)
yield from unique_everseen(chain(*sources), key=key)
def permalink(*, screen_name: str, id: str) -> str:
return f'https://twitter.com/{screen_name}/status/{id}'
# NOTE: tweets from archive are coming sorted by created_at
# NOTE: tweets from twint are also sorted by created_at?