Exemple #1
0
  def get(self):
    # Until we get this cron'd, query the entire datas set, generate
    # TimeSliceMetrics from it, and format them for display.
    today = datetime.date.today().isoformat()
    # logging.info(today)
    metrics = memcache.get('%s:global_stats' % today)
    # logging.info(metrics.created)
    if metrics is None:
      metrics = self.globalMetrics().get_result()
      # Cache for 2 hours
      memcache.set('%s:global_stats' % today, metrics, 60 * 60 * 2)

    # logging.info(metrics)
    jsonMetricsString = json.dumps(metrics, default=datamodel.toJSON,
                                   sort_keys=True, indent=2)

    if self.request.get("type") == "json":
      self.response.headers['Content-Type'] = "application/json"
      self.response.write(jsonMetricsString)
    else:
      template = templateEnv.get_template("report.html")
      self.response.write(template.render({
        "title": "Meaningless Global Stats",
        "content": datamodel.toJSON(metrics),
        "json": jsonMetricsString
      }))
Exemple #2
0
  def get(self):
    # Until we get this cron'd, query the entire datas set, generate
    # TimeSliceMetrics from it, and format them for display.
    metrics = self.globalMetrics().get_result()

    template = templateEnv.get_template("report.html")
    self.response.write(template.render({
      "title": "Meaningless Global Stats",
      "content": datamodel.toJSON(metrics),
      "json": json.dumps(metrics,
                         default=datamodel.toJSON,
                         sort_keys=True,
                         indent=2)
    }))