my.stackexchange: use proper pip package, add stat

+ 'anonymous' mode for stat() function
This commit is contained in:
Dima Gerasimov 2020-12-04 16:49:42 +00:00 committed by karlicoss
parent 9d39892e75
commit ddea816a49
6 changed files with 50 additions and 20 deletions

View file

@ -51,12 +51,12 @@ def articles() -> Iterable[Article]:
yield from _dal().articles()
def stats():
from .core import stat, Stats
def stats() -> Stats:
from itertools import chain
from more_itertools import ilen
# todo make stats more defensive?
return {
'articles' : ilen(articles()),
**stat(articles),
'highlights': ilen(chain.from_iterable(a.highlights for a in articles())),
}