Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(264)

Side by Side Diff: gm/rebaseline_server/column.py

Issue 376623002: rebaseline_server: allow JSON to control column filtering (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Ravi suggestions Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | gm/rebaseline_server/compare_to_expectations.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 2
3 """ 3 """
4 Copyright 2014 Google Inc. 4 Copyright 2014 Google Inc.
5 5
6 Use of this source code is governed by a BSD-style license that can be 6 Use of this source code is governed by a BSD-style license that can be
7 found in the LICENSE file. 7 found in the LICENSE file.
8 8
9 ColumnHeaderFactory class (see class docstring for details) 9 ColumnHeaderFactory class (see class docstring for details)
10 """ 10 """
11 11
12 # Keys used within dictionary representation of each column header. 12 # Keys used within dictionary representation of each column header.
13 # NOTE: Keep these in sync with static/constants.js 13 # NOTE: Keep these in sync with static/constants.js
14 KEY__EXTRACOLUMNHEADERS__HEADER_TEXT = 'headerText' 14 KEY__EXTRACOLUMNHEADERS__HEADER_TEXT = 'headerText'
15 KEY__EXTRACOLUMNHEADERS__HEADER_URL = 'headerUrl' 15 KEY__EXTRACOLUMNHEADERS__HEADER_URL = 'headerUrl'
16 KEY__EXTRACOLUMNHEADERS__IS_FILTERABLE = 'isFilterable' 16 KEY__EXTRACOLUMNHEADERS__IS_FILTERABLE = 'isFilterable'
17 KEY__EXTRACOLUMNHEADERS__IS_SORTABLE = 'isSortable' 17 KEY__EXTRACOLUMNHEADERS__IS_SORTABLE = 'isSortable'
18 KEY__EXTRACOLUMNHEADERS__USE_FREEFORM_FILTER = 'useFreeformFilter'
18 KEY__EXTRACOLUMNHEADERS__VALUES_AND_COUNTS = 'valuesAndCounts' 19 KEY__EXTRACOLUMNHEADERS__VALUES_AND_COUNTS = 'valuesAndCounts'
19 20
20 21
21 class ColumnHeaderFactory(object): 22 class ColumnHeaderFactory(object):
22 """Factory which assembles the header for a single column of data.""" 23 """Factory which assembles the header for a single column of data."""
23 24
24 def __init__(self, header_text, header_url=None, 25 def __init__(self, header_text, header_url=None,
25 is_filterable=True, is_sortable=True, 26 is_filterable=True, is_sortable=True,
26 include_values_and_counts=True): 27 use_freeform_filter=False):
27 """ 28 """
28 Args: 29 Args:
29 header_text: string; text the client should display within column header. 30 header_text: string; text the client should display within column header.
30 header_url: string; target URL if user clicks on column header. 31 header_url: string; target URL if user clicks on column header.
31 If None, nothing to click on. 32 If None, nothing to click on.
32 is_filterable: boolean; whether client should allow filtering on this 33 is_filterable: boolean; whether client should allow filtering on this
33 column. 34 column.
34 is_sortable: boolean; whether client should allow sorting on this column. 35 is_sortable: boolean; whether client should allow sorting on this column.
35 include_values_and_counts: boolean; whether the set of values found 36 use_freeform_filter: boolean; *recommendation* to the client indicating
36 within this column, and their counts, should be available for the 37 whether to allow freeform text matching, as opposed to listing all
37 client to display. 38 values alongside checkboxes. If is_filterable==false, this is
39 meaningless.
38 """ 40 """
39 self._header_text = header_text 41 self._header_text = header_text
40 self._header_url = header_url 42 self._header_url = header_url
41 self._is_filterable = is_filterable 43 self._is_filterable = is_filterable
42 self._is_sortable = is_sortable 44 self._is_sortable = is_sortable
43 self._include_values_and_counts = include_values_and_counts 45 self._use_freeform_filter = use_freeform_filter
44 46
45 def create_as_dict(self, values_and_counts_dict=None): 47 def create_as_dict(self, values_and_counts_dict=None):
46 """Creates the header for this column, in dictionary form. 48 """Creates the header for this column, in dictionary form.
47 49
48 Creates the header for this column in dictionary form, as needed when 50 Creates the header for this column in dictionary form, as needed when
49 constructing the JSON representation. Uses the KEY__EXTRACOLUMNHEADERS__* 51 constructing the JSON representation. Uses the KEY__EXTRACOLUMNHEADERS__*
50 constants as keys. 52 constants as keys.
51 53
52 Args: 54 Args:
53 values_and_counts_dict: dictionary mapping each possible column value 55 values_and_counts_dict: dictionary mapping each possible column value
54 to its count (how many entries in the column have this value), or 56 to its count (how many entries in the column have this value), or
55 None if this information is not available. 57 None if this information is not available.
56 """ 58 """
57 asdict = { 59 asdict = {
58 KEY__EXTRACOLUMNHEADERS__HEADER_TEXT: self._header_text, 60 KEY__EXTRACOLUMNHEADERS__HEADER_TEXT: self._header_text,
59 KEY__EXTRACOLUMNHEADERS__IS_FILTERABLE: self._is_filterable, 61 KEY__EXTRACOLUMNHEADERS__IS_FILTERABLE: self._is_filterable,
60 KEY__EXTRACOLUMNHEADERS__IS_SORTABLE: self._is_sortable, 62 KEY__EXTRACOLUMNHEADERS__IS_SORTABLE: self._is_sortable,
63 KEY__EXTRACOLUMNHEADERS__USE_FREEFORM_FILTER: self._use_freeform_filter,
61 } 64 }
62 if self._header_url: 65 if self._header_url:
63 asdict[KEY__EXTRACOLUMNHEADERS__HEADER_URL] = self._header_url 66 asdict[KEY__EXTRACOLUMNHEADERS__HEADER_URL] = self._header_url
64 if self._include_values_and_counts and values_and_counts_dict: 67 if values_and_counts_dict:
65 asdict[KEY__EXTRACOLUMNHEADERS__VALUES_AND_COUNTS] = sorted( 68 asdict[KEY__EXTRACOLUMNHEADERS__VALUES_AND_COUNTS] = sorted(
66 values_and_counts_dict.items()) 69 values_and_counts_dict.items())
67 return asdict 70 return asdict
OLDNEW
« no previous file with comments | « no previous file | gm/rebaseline_server/compare_to_expectations.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698