Commit f5c53ac5 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Add selection criteria on history.data in the selector.

parent c1647c31
......@@ -339,6 +339,7 @@
'Team': 'Équipe',
'teams': 'équipes',
'The aggregation function applies on the metric field. It is computed on the subset of row having a given values for the group_field x and y.': "La function d'agrégation est appliquée sur les valeurs du champ métrique. Elle est calculée sur le sous-ensemble d'enregisteremnts ayant une certain valeurs pour les champs 'group_field' x et y.",
'The field history.data contains the given value.': 'Le champ history.data contiens la valeur donnée.',
'the graphs': 'les graphiques',
'The graphs': 'Les graphiques',
'The lists': 'Les listes',
......
......@@ -2,6 +2,8 @@
""" selector
"""
tp_data = T("The field history.data contains the given value.")
virtdb.define_table('selector',
Field('year_start', 'integer', default=year),
Field('year_end', 'integer'),
......@@ -11,8 +13,8 @@ virtdb.define_table('selector',
Field('id_people_categories', 'reference alias_people_categories', label= T("People category")),
Field('id_people_code', 'reference people_categories', label= T("People quality")),
Field('id_object_categories', 'reference alias_object_categories', label= T("Object category")),
Field('id_object_code', 'reference object_categories', label= T("Object code")))
Field('id_object_code', 'reference object_categories', label= T("Object code")),
Field('data', 'string', comment=tp_data, label= T("Data")))
virtdb.selector.id_object_categories.requires = \
IS_IN_DB(db, 'alias_object_categories.category')
......
......@@ -131,7 +131,8 @@ class MySelector(SelectorActiveItems):
and year are systematically excluded.
"""
li = ['id_object_categories',
li = ['data',
'id_object_categories',
'id_object_code',
'id_people_categories',
'id_people_code',
......@@ -144,13 +145,16 @@ class MySelector(SelectorActiveItems):
# add virtual fields
db = current.globalenv['db']
db.people.age = Field.Virtual('age', self._age, ftype='integer')
db.history.coverage = Field.Virtual('coverage', self._coverage, ftype='double')
db.history.duration = Field.Virtual('duration', self._duration, ftype='double')
db.history.fte = Field.Virtual('fte', self._fte, ftype='double')
db.history.is_end = Field.Virtual('is_end', self._is_end, ftype='boolean')
db.history.is_over = Field.Virtual('is_over', self._is_over, ftype='boolean')
db.history.is_start = Field.Virtual('is_start', self._is_start, ftype='boolean')
history = db.history
virtual = Field.Virtual
db.people.age = virtual('age', self._age, ftype='integer')
history.coverage = virtual('coverage', self._coverage, ftype='double')
history.duration = virtual('duration', self._duration, ftype='double')
history.fte = virtual('fte', self._fte, ftype='double')
history.is_end = virtual('is_end', self._is_end, ftype='boolean')
history.is_over = virtual('is_over', self._is_over, ftype='boolean')
history.is_start = virtual('is_start', self._is_start, ftype='boolean')
def _age(self, row):
"""Compute the age of the person associated to the history record, now.
......@@ -318,35 +322,38 @@ class MySelector(SelectorActiveItems):
db = table._db
query = SelectorActiveItems.query(self, table)
# history data block contains
query &= db.history.data.contains(self.data)
# object category and code
id_object_code = self.id_object_code
if id_object_code:
q = db.history.id_object_categories == id_object_code
query = (query) & (q)
query &= db.history.id_object_categories == id_object_code
id_object_category = self.id_object_categories
if id_object_category:
category = db.object_categories[id_object_category].category
qcat = db.object_categories.category == category
myset = {row.id for row in db(qcat).select(db.object_categories.id)}
object_categories = db.object_categories
q = db.history.id_object_categories.belongs(myset)
query = (query) & (q)
category = object_categories[id_object_category].category
qcat = object_categories.category == category
myset = {row.id for row in db(qcat).select(object_categories.id)}
query &= db.history.id_object_categories.belongs(myset)
# people category and code
id_people_code = self.id_people_code
if id_people_code:
q = db.history.id_people_categories == id_people_code
query &= q
query &= db.history.id_people_categories == id_people_code
id_people_category = self.id_people_categories
if id_people_category:
category = db.people_categories[id_people_category].category
qcat = db.people_categories.category == category
myset = {row.id for row in db(qcat).select(db.people_categories.id)}
people_categories = db.people_categories
category = people_categories[id_people_category].category
qcat = people_categories.category == category
myset = {row.id for row in db(qcat).select(people_categories.id)}
q = db.history.id_people_categories.belongs(myset)
query &= q
query &= db.history.id_people_categories.belongs(myset)
return query
......
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