Commit 8966ce35 authored by Ryan Herbert's avatar Ryan Herbert Committed by Mikaël Salson

move group_concat to model

parent e7cca318
......@@ -189,3 +189,14 @@ def get_sample_set_id_from_results_file(results_file_id):
).select(db.sample_set_membership.sample_set_id).first().sample_set_id
return sample_set_id
def get_conf_list_select():
return "GROUP_CONCAT(DISTINCT CONCAT(config.id, ',', config.name, ',', fused_file.fused_file) SEPARATOR ';')"
def get_config_ids_select():
return "GROUP_CONCAT(DISTINCT config.id)"
def get_config_names_select():
return "GROUP_CONCAT(DISTINCT config.name)"
def get_group_names_select():
return "GROUP_CONCAT(DISTINCT auth_group.role)"
......@@ -6,6 +6,45 @@ class SampleSetList():
'''
def __init__(self, type, page=None, step=None, tags=None):
self.type = type
s_table = db[type]
left = [db.sample_set_membership.on(s_table.sample_set_id == db.sample_set_membership.sample_set_id),
db.sequence_file.on(db.sample_set_membership.sequence_file_id == db.sequence_file.id),
db.fused_file.on(s_table.sample_set_id == db.fused_file.sample_set_id),
db.config.on(db.fused_file.config_id == db.config.id)
]
group_configs = get_conf_list_select()
group_config_ids = get_config_ids_select()
group_config_names = get_config_names_select()
group_group_names = get_group_names_select()
self.result = []
print(db(
(s_table.sample_set_id > 0) &
(s_table.creator == db.auth_user.id)
)._select(
s_table.id.with_alias('id'),
s_table.sample_set_id.with_alias('sample_set_id'),
s_table.first_name.with_alias('first_name'),
s_table.last_name.with_alias('last_name'),
s_table.birth.with_alias('birth'),
s_table.info.with_alias('info'),
db.auth_user.last_name.with_alias('creator'),
db.sequence_file.size_file.sum().with_alias('size'),
db.sequence_file.id.count().with_alias('file_count'),
group_configs,
group_config_ids,
group_config_names,
#group_group_names,
left=left,
groupby= (s_table.id, s_table.sample_set_id, s_table.first_name, s_table.last_name, s_table.birth, s_table.info, db.auth_user.last_name),
orderby = ~db[type].id,
limitby=(0,1),
cacheable=True
))
limitby = None
if page is not None and step is not None:
......
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