Commit 616e8d95 authored by flothoni's avatar flothoni

server/.../sample_set.py

Make call on other set of a file in less number of db call
Link to #2728
parent 4a02536d
Pipeline #137404 passed with stages
in 17 minutes and 34 seconds
......@@ -124,22 +124,28 @@ def index():
)
)
listSets = []
## Phase 1; collect all set_id to construct SampleSets object
for row in query:
row.list_share_set = []
row.tmp_list_share_set = db(db.sample_set_membership.sequence_file_id == row.sequence_file.id).select()
for set_id in row.tmp_list_share_set:
if int(set_id.sample_set_id) != int(request.vars['id']):
listSets.append( set_id.sample_set_id )
samplesets = SampleSets(listSets)
setsvalues = samplesets.get_names()
## Phase 2; assign set to each rows
for row in query:
row.list_share_set = []
list_share_set = db(db.sample_set_membership.sequence_file_id == row.sequence_file.id).select()
for set_id in list_share_set:
for set_id in row.tmp_list_share_set:
if int(set_id.sample_set_id) != int(request.vars['id']):
sample_set = db(db.sample_set.id == set_id.sample_set_id).select()[0]
# Define value to show
if sample_set.sample_type == "patient":
name = db(db.patient.sample_set_id == set_id.sample_set_id).select()[0]
sample_set.title = name.last_name.upper() +" "+ name.first_name +" ("+str(name.birth)+")"
elif sample_set.sample_type == "run":
sample_set.title = db(db.run.sample_set_id == set_id.sample_set_id).select()[0].name
elif sample_set.sample_type == "generic":
sample_set.title = db(db.generic.sample_set_id == set_id.sample_set_id).select()[0].name
row.list_share_set.append(sample_set)
ID = set_id.sample_set_id
## Filter to keep only set specific at this row
for elt in samplesets.sample_sets:
if elt.id == ID:
values = {"title": setsvalues[ID], "sample_type": elt["sample_type"], "id":ID}
row.list_share_set.append( values )
tag_decorator = TagDecorator(get_tag_prefix())
......
......@@ -90,9 +90,10 @@
<td>
<!-- Select set with this sample -->
{{ for sample_set in row.list_share_set:}}
{{ print(sample_set) }}
<!-- Show values -->
<span class="{{ =sample_set.sample_type }}_token set_token" title="{{ =sample_set.title }}" onclick="db.call('sample_set/index', {'id': '{{ =int(sample_set.id) }}', 'config_id': -1 })" >
{{ =sample_set.title }}
<span class="{{ =sample_set['sample_type'] }}_token set_token" title="{{ =sample_set['title'] }}" onclick="db.call('sample_set/index', {'id': '{{ =int(sample_set['id']) }}', 'config_id': -1 })" >
{{ =sample_set['title'] }}
</span>
{{ pass }}
</td>
......
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