Commit bb3f1835 authored by HERBERT Ryan's avatar HERBERT Ryan
Browse files

controllers/default.py file.py patient.py removing unnecessary joins from new queries

parent 10a81cfd
......@@ -289,7 +289,6 @@ def get_custom_data():
patient_id = db((db.sequence_file.id == sequence_file_id)
& (db.sample_set_membership.sequence_file_id == db.sequence_file.id)
& (db.sample_set.id == db.sample_set_membership.sample_set_id)
& (db.sample_set.sample_type == 'patient')
& (db.patient.sample_set_id == db.sample_set.id)
).select(db.patient.id).first()
......
......@@ -20,9 +20,7 @@ def add():
return error_message("you don't have right to upload files")
else:
query = db((db.patient.id == request.vars['id'])
&(db.sample_set.id == db.patient.sample_set_id)
&(db.sample_set.sample_type == 'patient')
&(db.sample_set_membership.sample_set_id == db.sample_set.id)
&(db.sample_set_membership.sample_set_id == db.patient.sample_set_id)
&(db.sequence_file.id == db.sample_set_membership.sequence_file_id)
).select(db.sequence_file.ALL)
if len(query) != 0 :
......@@ -50,9 +48,7 @@ def add_form():
if error=="" :
query = db((db.patient.id == request.vars['patient_id'])
&(db.sample_set.id == db.patient.sample_set_id)
&(db.sample_set.sample_type == 'patient')
&(db.sample_set_membership.sample_set_id == db.sample_set.id)
&(db.sample_set_membership.sample_set_id == db.patient.sample_set_id)
&(db.sequence_file.id == db.sample_set_membership.sequence_file_id)
).select(db.sequence_file.ALL)
for row in query :
......@@ -129,9 +125,7 @@ def edit_form():
patient_id = db((db.sequence_file.id == request.vars["id"])
&(db.sample_set_membership.sequence_file_id == db.sequence_file.id)
&(db.sample_set.id == db.sample_set_membership.sample_set_id)
&(db.sample_set.sample_type == 'patient')
&(db.patient.sample_set_id == db.sample_set.id)
&(db.patient.sample_set_id == db.sample_set_membership.sample_set_id)
).select(db.patient.id).first().id
res = {"file_id" : request.vars['id'],
......@@ -154,9 +148,7 @@ def upload():
if not error:
patient_id = db((db.sequence_file.id == request.vars["id"])
&(db.sample_set_membership.sequence_file_id == db.sequence_file.id)
&(db.sample_set.id == db.sample_set_membership.sample_set_id)
&(db.sample_set.sample_type == 'patient')
&(db.patient.sample_set_id == db.sample_set.id)
&(db.patient.sample_set_id == db.sample_set_membership.sample_set_id)
).select(db.patient.id).first()
mes += "file %s (%s): " % (request.vars['id'], patient_id)
res = {"message": mes + "processing uploaded file",
......
......@@ -77,9 +77,7 @@ def info():
query2 = db(
(db.sequence_file.id == db.sample_set_membership.sequence_file_id)
& (db.sample_set_membership.sample_set_id == db.sample_set.id)
& (db.sample_set.sample_type == 'patient')
& (db.sample_set.id == db.patient.sample_set_id)
& (db.sample_set_membership.sample_set_id == db.patient.sample_set_id)
& (db.patient.id==request.vars["id"])
).select(
left=db.results_file.on(
......@@ -98,9 +96,7 @@ def info():
query = db(
(db.sequence_file.id == db.sample_set_membership.sequence_file_id)
& (db.sample_set_membership.sample_set_id == db.sample_set.id)
& (db.sample_set.sample_type == 'patient')
& (db.sample_set.id == db.patient.sample_set_id)
& (db.sample_set_membership.sample_set_id == db.patient.sample_set_id)
& (db.patient.id==request.vars["id"])
).select(
left=db.results_file.on(
......
......@@ -58,9 +58,7 @@ class DefaultController(unittest.TestCase):
request.vars['sequence_file_id'] = fake_file_id
patient = db((db.sequence_file.id == fake_file_id)
& (db.sequence_file.id == db.sample_set_membership.sequence_file_id)
& (db.patient.sample_set_id == db.sample_set.id)
& (db.sample_set.sample_type == 'patient')
& (db.sample_set.id == db.sample_set_membership.sample_set_id)
& (db.patient.sample_set_id == db.sample_set_membership.sample_set_id)
).select(db.patient.ALL).first()
request.vars['patient_id'] = patient.id
......
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