Commit 1de86b6c authored by Arthur Lutz's avatar Arthur Lutz
Browse files

skip unknown eid and pretty print

parent 2495e993f1cf
...@@ -9,7 +9,7 @@ This command will generate webstats objects for all linked document types. ...@@ -9,7 +9,7 @@ This command will generate webstats objects for all linked document types.
from datetime import datetime from datetime import datetime
from logilab.common.date import first_day, last_day from logilab.common.date import first_day, last_day
from cubicweb import cwconfig from cubicweb import cwconfig, UnknownEid
from cubicweb import AuthenticationError from cubicweb import AuthenticationError
from cubicweb.dbapi import in_memory_repo_cnx from cubicweb.dbapi import in_memory_repo_cnx
...@@ -89,7 +89,11 @@ class UpdateWebstatsCommand(Command): ...@@ -89,7 +89,11 @@ class UpdateWebstatsCommand(Command):
for eid, values in count_dict.items(): for eid, values in count_dict.items():
visit_count = visit_count_rdf = 0 visit_count = visit_count_rdf = 0
total_hits = sum([item[0] for item in values]) total_hits = sum([item[0] for item in values])
entity = session.entity_from_eid(eid) try:
entity = session.entity_from_eid(eid)
except UnknownEid:
update_stats['skipped'] += 1
continue
if not entity.__regid__ in allowed_types: if not entity.__regid__ in allowed_types:
update_stats['skipped'] += 1 update_stats['skipped'] += 1
continue continue
...@@ -115,7 +119,12 @@ class UpdateWebstatsCommand(Command): ...@@ -115,7 +119,12 @@ class UpdateWebstatsCommand(Command):
period=stats_period, period=stats_period,
stats_about = entity, stats_about = entity,
hit_type=is_rdf and u'rdf' or u'normal') hit_type=is_rdf and u'rdf' or u'normal')
print update_stats print '''=== Update Report ===
Number of stat objects created : %(created)s
Number of stat objects updated : %(updated)s
Number of stat objects already existed : %(exists no change)s
Number of stat objects skipped : %(skipped)s
''' % update_stats
def _init_cw_connection(self, appid): def _init_cw_connection(self, appid):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment