core: add helper for computing stats; use it in modules

This commit is contained in:
Dima Gerasimov 2020-06-04 22:19:34 +01:00
parent a94b64c273
commit 1cc4eb5d8d
10 changed files with 79 additions and 3 deletions

View file

@ -108,3 +108,11 @@ def likes() -> Iterable[Tweet]:
db = _get_db()
res = db.query(_QUERY.format(where='F.tweet_id IS NOT NULL'))
yield from map(Tweet, res)
def stats():
from ..core import stat
return {
**stat(tweets),
**stat(likes),
}