3 # Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
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.
11 """Loads coverage data from the database."""
13 __author__
= 'phoglund@webrtc.org (Patrik Höglund)'
17 from google
.appengine
.ext
import db
21 class CoverageDataLoader
:
22 """ Loads coverage data from the database."""
24 def load_coverage_json_data(self
, report_category
):
25 coverage_entries
= db
.GqlQuery('SELECT * '
27 'WHERE report_category = :1 '
28 'ORDER BY date ASC', report_category
)
30 for coverage_entry
in coverage_entries
:
31 # Note: The date column must be first in alphabetical order since it is
32 # the primary column. This is a bug in the gviz api (or at least it
33 # doesn't make much sense).
34 data
.append({'aa_date': coverage_entry
.date
,
35 'line_coverage': coverage_entry
.line_coverage
,
36 'function_coverage': coverage_entry
.function_coverage
,
37 'branch_coverage': coverage_entry
.branch_coverage
,
41 'aa_date': ('datetime', 'Date'),
42 'line_coverage': ('number', 'Line Coverage'),
43 'function_coverage': ('number', 'Function Coverage'),
44 'branch_coverage': ('number', 'Branch Coverage'),
46 coverage_data
= gviz_api
.DataTable(description
, data
)
47 return coverage_data
.ToJSon(order_by
='date')