Commit e8cd2110 authored by Ryan Herbert's avatar Ryan Herbert

sample_set.py use query aliases instead of lambda functions

This actually currently breaks the usage of helpers to display set
names, but it should be faster.

See #2235
parent b8f84321
...@@ -654,12 +654,7 @@ def custom(): ...@@ -654,12 +654,7 @@ def custom():
group_ids=group_ids) group_ids=group_ids)
def getStatHeaders(): def getStatHeaders():
return [ return ['set_id', 'set_name', 'set_info']
('set_id', lambda x, y, z: x.sample_set.id),
('set_name', lambda x, y, z: z[y].get_name(x[y])),
('set_info', lambda x, y, z: z[y].get_info(x[y])),
('config', lambda x, y, z: x.config.name)
]
def getResultsFileStats(file_name, dest): def getResultsFileStats(file_name, dest):
file_path = "%s%s" % (defs.DIR_RESULTS, file_name) file_path = "%s%s" % (defs.DIR_RESULTS, file_name)
...@@ -683,8 +678,13 @@ def getStatData(results_file_ids): ...@@ -683,8 +678,13 @@ def getStatData(results_file_ids):
(db.sample_set.id == db.sample_set_membership.sample_set_id) & (db.sample_set.id == db.sample_set_membership.sample_set_id) &
(db.config.id == db.results_file.config_id) (db.config.id == db.results_file.config_id)
).select( ).select(
db.results_file.ALL, db.sample_set.ALL, db.patient.ALL, db.run.ALL, db.generic.ALL, db.results_file.data_file.with_alias("results_file"),
db.config.ALL, db.sample_set.id.with_alias("set_id"),
db.sample_set.sample_type.with_alias("sample_type"),
db.patient.first_name.with_alias("set_name"), db.patient.last_name, db.patient.info.with_alias('set_info'),
db.run.name,
db.generic.name,
db.config.name,
left = [ left = [
db.patient.on(db.patient.sample_set_id == db.sample_set.id), db.patient.on(db.patient.sample_set_id == db.sample_set.id),
db.run.on(db.run.sample_set_id == db.sample_set.id), db.run.on(db.run.sample_set_id == db.sample_set.id),
...@@ -695,16 +695,17 @@ def getStatData(results_file_ids): ...@@ -695,16 +695,17 @@ def getStatData(results_file_ids):
data = [] data = []
for res in query: for res in query:
d = {} d = {}
set_type = res.sample_set.sample_type set_type = res.sample_type
for head, func in getStatHeaders(): headers = getStatHeaders()
d[head] = func(res, set_type, helpers) for head in headers:
d = getResultsFileStats(res.results_file.data_file, d) d[head] = res[head]
d = getResultsFileStats(res.results_file, d)
data.append(d) data.append(d)
return data return data
def multi_sample_stats(): def multi_sample_stats():
data = {} data = {}
data['headers'] = [h for h, f in getStatHeaders()] data['headers'] = getStatHeaders()
results = [] results = []
#if not auth.can_view_sample_set(): #if not auth.can_view_sample_set():
# return "permission denied %s" % res # return "permission denied %s" % res
......
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