--- /dev/null
+{% extends "stasy-base-2.html" %}
+
+{% block title %}{% end block %}
+
+{% block content %}
+ <h3>Need a headline</h3>
+
+ <table>
+ <tr>
+ <td>
+ {{ _("Sending profiles") }}
+ </td>
+ <td>
+ {{ profiles_count }} / {{ profiles_count_all }}
+ </td>
+ </tr>
+ <tr>
+ <td>
+ {{ _("Archive size") }}
+ </td>
+ <td>
+ {{ archives_count }}
+ </td>
+ </tr>
+ </table>
+
+ <h3>{{ _("Updates in the last 24 hours") }}</h3>
+ {{ modules.StasyTable(updated_since_24h, percentage=False, sortby="percentage") }}
+{% end block %}
+
from __future__ import division
+import datetime
import hwdata
import logging
import pymongo
# a given date
# All distinct profiles (based on public_id)
- return self._db.profiles.distinct("public_id").count()
+ # XXX possibly bad performance
+ return len(self._db.profiles.distinct("public_id"))
+
+ def get_archives_count(self):
+ return self._db.archives.count()
#def _get_profile_cursor(self, public_id):
# c = self._db.profiles.find({ "public_id" : public_id })
return zones
+ def get_profile_ratio(self):
+ return (self.query({}).count(), self.get_profile_count())
+
+ def get_updated_since(self, since, _query={}):
+ since = datetime.datetime.utcnow() - datetime.timedelta(**since)
+
+ query = { "updated" : { "$gte" : since }}
+ query.update(_query)
+
+ return self.query(query)
+
+ def get_updates_by_release_since(self, since):
+ updates = {}
+
+ for release in self.releases:
+ updates[release] = self.get_updated_since(since,
+ { "profile.system.release" : release }).count()
+
+ return updates
+
if __name__ == "__main__":
s = Stasy()
model_id=model_id,
model_name=model_name,
percentage=percentage)
+
+
+class StasyStatsAdminHandler(StasyBaseHandler):
+ def get(self):
+ _ = self.locale.translate
+
+ data = {}
+
+ data["profiles_count"], data["profiles_count_all"] = \
+ self.stasy.get_profile_ratio()
+
+ data["archives_count"] = self.stasy.get_archives_count()
+
+ # updated since 24h
+ since = { "hours" : 24 }
+ updates = self.stasy.get_updates_by_release_since(since)
+ #updates[_("All versions")] = self.stasy.get_updated_since(since).count()
+ data["updated_since_24h"] = updates
+
+ self.render("stasy-stats-admin.html", **data)
+