Commit 49fb261b authored by Ryan Herbert's avatar Ryan Herbert

controllers/sample_set.py refactor getStatHeaders

getStatHeaders now returns a list of pairs. the first element is the
header key, the second is a lambda function that will return the desired
value from the query result.
See #2235
parent 00ffd004
...@@ -652,7 +652,9 @@ def custom(): ...@@ -652,7 +652,9 @@ def custom():
group_ids=group_ids) group_ids=group_ids)
def getStatHeaders(): def getStatHeaders():
return ['set_name'] return [
('set_name', lambda x, y, z: z[y].get_name(x[y]))
]
def getStatData(results_file_ids): def getStatData(results_file_ids):
mf = ModelFactory() mf = ModelFactory()
...@@ -678,13 +680,14 @@ def getStatData(results_file_ids): ...@@ -678,13 +680,14 @@ def getStatData(results_file_ids):
for res in query: for res in query:
d = {} d = {}
set_type = res.sample_set.sample_type set_type = res.sample_set.sample_type
d['set_name'] = helpers[set_type].get_name(res[set_type]) for head, func in getStatHeaders():
d[head] = func(res, set_type, helpers)
data.append(d) data.append(d)
return data return data
def multi_sample_stats(): def multi_sample_stats():
data = {} data = {}
data['headers'] = getStatHeaders() data['headers'] = [h for h, f in 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