Commit 5d584287 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Rename the fileds (column, row) of the metrics table by (horizontal, vertical).

parent 55bf8be3
......@@ -33,20 +33,17 @@ def index():
metric = db.metrics[selector.id_metrics]
# database fields corresponding to the axes
# correspondence is (column, row) = (y, x)
fields, orderby = [], []
for el in ('column', 'row'):
fields, orderby = {}, {}
for el in ('vertical', 'horizontal'):
axis = metric["axis_%s" % el]
granularity = metric["granularity_%s" % el]
direction = metric["direction_%s" % el]
field = db[axis][granularity]
if direction == 'DESC':
field = ~field
fields[el] = field
orderby[el] = ~field if direction == 'DESC' else field
# query directive to count publications including
# foreign key constraints and user requirements
......@@ -66,56 +63,57 @@ def index():
query = (query) & ((q_start) & (q_end))
# get the label along the x and y axis
# x axis is horizontal while the y axis is vertical
# correspondence is (column, row) = (y, x)
header_y, field = [], fields[0]
for row in db(query).select(fields[0], distinct=True, orderby=orderby[0]):
header_x, field = [], fields[1]
for row in db(query).select(fields[1], distinct=True, orderby=orderby[1]):
labels = {}
for el in ('vertical', 'horizontal'):
labels[el] = []
for row in db(query).select(fields[el], distinct=True, orderby=orderby[el]):
# the fields configuration of the
# it include a sum per row
cfg = dict(fields=[], data=[])
cfg['fields'].append({'name': fields[0].name, 'type': 'string'})
for el in header_x:
# first column contains labels for the vertical axis
cfg['fields'].append({'name': fields['vertical'].name, 'type': 'string'})
# one column for each horizontal label
for el in labels['horizontal']:
cfg['fields'].append({'name': str(el), 'type': 'int'})
# last column contains the sum of the row
cfg['fields'].append({'name': T('Total'), 'type': 'int'})
# fill the data block of the
# transform (x, y count) data point into a row of values
# sum the content of the row
count =
rows = db(query).select(fields[0],
rows = db(query).select(fields['vertical'],
groupby=(fields['vertical'], fields['horizontal']),
orderby=(orderby['vertical'], orderby['horizontal']))
key = None
for row in rows:
if row[fields[0]] != key:
key = row[fields[0]]
if row[fields['vertical']] != key:
key = row[fields['vertical']]
cfg['data'][-1].extend(['']*(len(header_x) + 1))
cfg['data'][-1].extend(['']*(len(labels['horizontal']) + 1))
cfg['data'][-1][-1] = 0
i = header_x.index(row[fields[1]]) + 1
i = labels['horizontal'].index(row[fields['horizontal']]) + 1
cfg['data'][-1][i] = row[count]
cfg['data'][-1][-1] += row[count]
# Substitute axis label
cvt_labels = get_converter(metric)
# label for the horizontal axis
for i in range(len(cfg['data'][0])):
if cfg['data'][0][i] in cvt_labels:
cfg['data'][0][i] = cvt_labels[cfg['data'][0][i]]
# label for the vertical axis
for i in range(len(cfg['data'])):
if cfg['data'][i][0] in cvt_labels:
cfg['data'][i][0] = cvt_labels[cfg['data'][i][0]]
......@@ -67,8 +67,10 @@
'Axis Granularity Projects': 'Axis Granularity Projects',
'Axis Granularity Teams': 'Axis Granularity Teams',
'Axis Granularity Time': 'Axis Granularity Time',
'Axis Horizontal': 'Axis Horizontal',
'Axis Label Converters': 'Axis Label Converters',
'Axis values are used to defined the title of each level in section. This field allow to replace some values by another ones. Rule: label1: "value1", label2: "value2",....': "Le nom de l'axe est utilisé comme titre pour le niveau. Ce champ permet de remplacer cette valeur par une autre. Régle: label1: 'value1', label2: 'value2',....",
'Axis Vertical': 'Axis Vertical',
'basic': 'basic',
'Binary files': 'fichiers binaires',
'Book': 'Ouvrage',
......@@ -173,11 +175,13 @@
'Direct access to the table: ': 'Accès direct à la table : ',
'Direction': 'Direction',
'Direction Column': 'Direction Column',
'Direction Horizontal': 'Direction Horizontal',
'Direction Level 1': 'Direction Level 1',
'Direction Level 2': 'Direction Level 2',
'Direction Level 3': 'Direction Level 3',
'Direction Level 4': 'Direction Level 4',
'Direction Row': 'Direction Row',
'Direction Vertical': 'Direction Vertical',
'Directors': 'Directeurs',
'Documentation for developers': 'Documentation développeurs',
'documentations': 'documentations',
......@@ -243,11 +247,13 @@
'granularity': 'granularité',
'Granularity': 'Granularité',
'Granularity Column': 'Granularity Column',
'Granularity Horizontal': 'Granularity Horizontal',
'Granularity Level 1': 'Granularity Level 1',
'Granularity Level 2': 'Granularity Level 2',
'Granularity Level 3': 'Granularity Level 3',
'Granularity Level 4': 'Granularity Level 4',
'Granularity Row': 'Granularity Row',
'Granularity Vertical': 'Granularity Vertical',
'Grids': 'Tables',
'Group': 'Groupe',
'Group %(group_id)s created': 'Group %(group_id)s created',
......@@ -265,6 +271,7 @@
'Header / Footer': 'Header / Footer',
'Header/Footer': 'Header/Footer',
'Help': 'Aide',
'Horizontal': 'Horizontal',
'Host': 'Host',
'HTTP Error': 'HTTP Error',
'id': 'id',
......@@ -637,6 +644,7 @@
'value not in database': 'value not in database',
'Verify Password': 'Verify Password',
'versions': 'versions',
'Vertical': 'Vertical',
'volume': 'volume',
'Volume': 'Volume',
'Volume / pages': 'Volume / pages',
......@@ -14,12 +14,12 @@ T("can be applied on any field of the table using the SQL WHERE syntax. "
Field("metric", "string", length=255, notnull=True),
Field("definition", "text", default=""),
Field("axis_column", "string", default="", length=255, label=T('Columns')),
Field("axis_row", "string", default="", length=255, label=T('Rows')),
Field("granularity_column", "string", length=255),
Field("granularity_row", "string", length=255),
Field("direction_column", "string", length=255, default="ASC"),
Field("direction_row", "string", length=255, default="ASC"),
Field("axis_vertical", "string", default="", length=255),
Field("axis_horizontal", "string", default="", length=255),
Field("granularity_vertical", "string", length=255),
Field("granularity_horizontal", "string", length=255),
Field("direction_vertical", "string", length=255, default="ASC"),
Field("direction_horizontal", "string", length=255, default="ASC"),
Field("axis_label_converters", "text", comment=tp_axis_label, default="", label="Converters"),
Field("conditions", "text", comment=tp_conditions, default=""),
Field("header_flag", "boolean", default=True, label="Header"),
......@@ -28,5 +28,5 @@ db.define_table("metrics",
db.metrics.metric.filter_in = dbui.CLEAN_SPACES
db.metrics.direction_column.requires = IS_IN_SET(DIRS)
db.metrics.direction_row.requires = IS_IN_SET(DIRS)
\ No newline at end of file
db.metrics.direction_horizontal.requires = IS_IN_SET(DIRS)
db.metrics.direction_vertical.requires = IS_IN_SET(DIRS)
\ No newline at end of file
......@@ -12,7 +12,7 @@ fieldsModifier = dbui.FieldsModifier('metrics')
fieldsModifier.configure_field('axis_label_converters', height=260)
fieldsModifier.configure_field('definition', height=233)
for el in ('column', 'row'):
for el in ('vertical', 'horizontal'):
fieldsModifier.configure_field('axis_%s' % el,
itemId='axis_%s' % el,
......@@ -50,8 +50,8 @@ formModifier.merge_fields('metric',
title=T('Count by'))
......@@ -78,12 +78,12 @@ formModifier.configure(buttonAlign='right',
gridModifier = dbui.GridModifier('metrics')
gridModifier.configure_column('metric', width=90)
gridModifier.configure_column('definition', width=250)

98.6 KB | W: | H:


98.2 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment