| 463 | |
| 464 | |
| 465 | class 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 | |
| 490 | class block: |