core: add helper for computing stats; use it in modules
This commit is contained in:
parent
a94b64c273
commit
1cc4eb5d8d
10 changed files with 79 additions and 3 deletions
|
@ -66,6 +66,13 @@ def events() -> Iterable[Res[Event]]:
|
|||
yield e
|
||||
|
||||
|
||||
def stats():
|
||||
from ..core import stat
|
||||
return {
|
||||
**stat(events),
|
||||
}
|
||||
|
||||
|
||||
# TODO typing.TypedDict could be handy here..
|
||||
def _parse_common(d: Dict) -> Dict:
|
||||
url = d['url']
|
||||
|
|
|
@ -29,7 +29,7 @@ class github(user_config):
|
|||
def dal_module(self):
|
||||
rpath = self.ghexport
|
||||
if rpath is not None:
|
||||
from .core.common import import_dir
|
||||
from ..core.common import import_dir
|
||||
return import_dir(rpath, '.dal')
|
||||
else:
|
||||
import my.config.repos.ghexport.dal as dal
|
||||
|
@ -81,6 +81,13 @@ def events(dal=_dal()) -> Results:
|
|||
yield _parse_event(d)
|
||||
|
||||
|
||||
def stats():
|
||||
from ..core import stat
|
||||
return {
|
||||
**stat(events),
|
||||
}
|
||||
|
||||
|
||||
# TODO hmm. need some sort of abstract syntax for this...
|
||||
# TODO split further, title too
|
||||
def _get_summary(e) -> Tuple[str, Optional[str], Optional[str]]:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue