Commit 0cc84aa4 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Update the metric selector to add the author criteria.

parent 3a9980e7
......@@ -15,13 +15,13 @@ def index():
"""Main Controller handling metrics.
"""
publications = db.publications
# get the user constraint.
# the selector fields year_start, year_end, id_lists are excluded
# from the selector query.
selector = Selector(virtdb.metric_selector,
exclude_fields=('year_start',
'year_end',
'id_metrics'))
tpl = ('author', 'year_start', 'year_end', 'id_metrics')
selector = Selector(virtdb.metric_selector, exclude_fields=tpl)
# protection
if not selector.id_metrics:
......@@ -46,19 +46,23 @@ def index():
# query directive to count publications including
# foreign key constraints and user requirements
# related to team, project and year
query = selector.query(db.publications)
query = selector.query(publications)
if metric.conditions:
q_conditions = smart_query(db.publications, metric.conditions)
query = (query) & (q_conditions)
q_conditions = smart_query(publications, metric.conditions)
query &= q_conditions
if selector.year_start and not selector.year_end:
query = (query) & (db.publications.year == selector.year_start)
query &= (publications.year == selector.year_start)
elif selector.year_start and selector.year_end:
q_start = db.publications.year >= selector.year_start
q_end = db.publications.year <= selector.year_end
query = (query) & ((q_start) & (q_end))
q_start = publications.year >= selector.year_start
q_end = publications.year <= selector.year_end
query &= ((q_start) & (q_end))
if selector.author:
q_author = publications.authors_institute.contains(selector.author)
query &= q_author
# get the label along the x and y axis
labels = {}
......@@ -89,7 +93,7 @@ def index():
# fill the data block of the Ext.data.Array.Store
# transform (x, y count) data point into a row of values
# sum the content of the row
count = db.publications.id.count()
count = publications.id.count()
rows = db(query).select(fields['vertical'],
fields['horizontal'],
count,
......
......@@ -13,6 +13,7 @@ virtdb.define_table('metric_selector',
Field('id_teams', 'reference teams', label='Team'),
Field('id_projects', 'reference projects', label='Project'),
Field('id_categories', 'reference categories', label='Category'),
Field('author', 'string'),
Field('id_authors_roles', 'reference authors_roles', label='Role'),
Field('id_metrics', 'reference metrics', label='Metric'))
......
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