blob: 5cc5a611819ed508f78ae83e056d5f32b0448983 [file] [log] [blame]
phoglund@webrtc.orgd4f0a0e2012-02-01 10:59:23 +00001#!/usr/bin/env python
2#-*- coding: utf-8 -*-
3# Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
4#
5# Use of this source code is governed by a BSD-style license
6# that can be found in the LICENSE file in the root of the source
7# tree. An additional intellectual property rights grant can be found
8# in the file PATENTS. All contributing project authors may
9# be found in the AUTHORS file in the root of the source tree.
10
11"""Implements the quality tracker dashboard and reporting facilities."""
12
13__author__ = 'phoglund@webrtc.org (Patrik Höglund)'
14
phoglund@webrtc.org86ce46d2012-02-06 10:55:12 +000015from google.appengine.ext.webapp import template
phoglund@webrtc.orgd4f0a0e2012-02-01 10:59:23 +000016import webapp2
17
18import add_build_status_data
19import add_coverage_data
phoglund@webrtc.org86ce46d2012-02-06 10:55:12 +000020import load_build_status
21import load_coverage
phoglund@webrtc.orgd4f0a0e2012-02-01 10:59:23 +000022
23
24class ShowDashboard(webapp2.RequestHandler):
25 """Shows the dashboard page.
26
27 The page is shown by grabbing data we have stored previously
28 in the App Engine database using the AddCoverageData handler.
29 """
30
31 def get(self):
phoglund@webrtc.org86ce46d2012-02-06 10:55:12 +000032 build_status_loader = load_build_status.BuildStatusLoader()
33 build_status_data = build_status_loader.load_build_status_data()
34 last_updated_at = build_status_loader.load_last_modified_at()
phoglund@webrtc.org914ef272012-02-27 15:42:25 +000035 if last_updated_at is None:
36 self._show_error_page("No data has yet been uploaded to the dashboard.")
37 return
38
phoglund@webrtc.org86ce46d2012-02-06 10:55:12 +000039 last_updated_at = last_updated_at.strftime("%Y-%m-%d %H:%M")
40 lkgr = build_status_loader.compute_lkgr()
phoglund@webrtc.orgd4f0a0e2012-02-01 10:59:23 +000041
phoglund@webrtc.org86ce46d2012-02-06 10:55:12 +000042 coverage_loader = load_coverage.CoverageDataLoader()
43 coverage_json_data = coverage_loader.load_coverage_json_data()
phoglund@webrtc.orgd4f0a0e2012-02-01 10:59:23 +000044
phoglund@webrtc.org86ce46d2012-02-06 10:55:12 +000045 page_template_filename = 'templates/dashboard_template.html'
46 self.response.write(template.render(page_template_filename, vars()))
phoglund@webrtc.orgd4f0a0e2012-02-01 10:59:23 +000047
48 def _show_error_page(self, error_message):
49 self.response.write('<html><body>%s</body></html>' % error_message)
50
51
52app = webapp2.WSGIApplication([('/', ShowDashboard),
53 ('/add_coverage_data',
54 add_coverage_data.AddCoverageData),
55 ('/add_build_status_data',
56 add_build_status_data.AddBuildStatusData)],
57 debug=True)