MCPcopy Create free account
hub / github.com/internetarchive/openlibrary / stats

Class stats

openlibrary/plugins/admin/code.py:465–487  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

463
464
465class stats:
466 def GET(self, today):
467 json = web.ctx.site._conn.request(web.ctx.site.name, "/get", "GET", {"key": "/admin/stats/" + today})
468 return delegate.RawText(json)
469
470 def POST(self, today):
471 """Update stats for today."""
472 doc = self.get_stats(today)
473 doc._save(action="create-stats")
474 raise web.seeother(web.ctx.path)
475
476 def get_stats(self, today):
477 stats = web.ctx.site._request("/stats/" + today)
478
479 key = "/admin/stats/" + today
480 doc = web.ctx.site.new(key, {"key": key, "type": {"key": "/type/object"}})
481 doc.edits = {
482 "human": stats.edits - stats.edits_by_bots,
483 "bot": stats.edits_by_bots,
484 "total": stats.edits,
485 }
486 doc.members = stats.new_accounts
487 return doc
488
489
490class block:

Callers 1

get_admin_statsFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected