blob: eafed3b3305f8977b61e6e51416f93455e2c47d4 [file] [log] [blame]
phoglund@webrtc.org86ce46d2012-02-06 10:55:12 +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"""Loads coverage data from the database."""
12
13__author__ = 'phoglund@webrtc.org (Patrik Höglund)'
14
15from google.appengine.ext import db
16import gviz_api
17
18
19class CoverageDataLoader:
20 """ Loads coverage data from the database."""
21
22 def load_coverage_json_data(self):
23 coverage_entries = db.GqlQuery('SELECT * '
24 'FROM CoverageData '
25 'ORDER BY date ASC')
26 data = []
27 for coverage_entry in coverage_entries:
28 data.append({'date': coverage_entry.date,
29 'line_coverage': coverage_entry.line_coverage,
30 'function_coverage': coverage_entry.function_coverage,
31 })
32
33 description = {
34 'date': ('datetime', 'Date'),
35 'line_coverage': ('number', 'Line Coverage'),
36 'function_coverage': ('number', 'Function Coverage')
37 }
38 coverage_data = gviz_api.DataTable(description, data)
39 return coverage_data.ToJSon(order_by='date')