Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
limbra
limbra
Commits
0cc84aa4
Commit
0cc84aa4
authored
Jun 30, 2016
by
LE GAC Renaud
Browse files
Update the metric selector to add the author criteria.
parent
3a9980e7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
12 deletions
+17
-12
controllers/metrics.py
controllers/metrics.py
+16
-12
models/vt_metric_selector.py
models/vt_metric_selector.py
+1
-0
No files found.
controllers/metrics.py
View file @
0cc84aa4
...
...
@@ -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
,
...
...
models/vt_metric_selector.py
View file @
0cc84aa4
...
...
@@ -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'
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment