Commit 04a8695e authored by Ryan Herbert's avatar Ryan Herbert

refactor set models filter method

We want to build a modular search string so we can have a reduced list
of columns.
parent f942c703
......@@ -84,6 +84,13 @@ class SampleSet(object):
&(db.results_file.sequence_file_id == db.sequence_file.id)).count()
return data.data_count
def create_filter_string(self, data, keys):
for row in data:
row['string'] = []
for key in keys:
if key in row:
row['string'].append(str(row[key]))
@abstractmethod
def filter(self, filter_str, data):
pass
......
......@@ -7,8 +7,8 @@ class Generic(SampleSet):
return 'set'
def filter(self, filter_str, data):
for row in data:
row['string'] = [row['name'], row['confs'], row['groups'], str(row['info'])]
keys = ['name', 'confs', 'groups', 'info']
self.create_filter_string(data, keys)
return filter(lambda row : vidjil_utils.advanced_filter(row['string'], filter_str), data)
def get_info_dict(self, data):
......
......@@ -17,8 +17,8 @@ class Patient(SampleSet):
return "%s" % str(data.birth) if data.birth is not None else ''
def filter(self, filter_str, data):
for row in data:
row['string'] = [row['last_name'], row['first_name'], row['confs'], row['groups'], str(row['birth']), str(row['info'])]
keys = ['last_name', 'first_name', 'confs', 'groups', 'birth', 'info']
self.create_filter_string(data, keys)
return filter(lambda row : vidjil_utils.advanced_filter(row['string'], filter_str), data)
def get_info_dict(self, data):
......
......@@ -17,8 +17,8 @@ class Run(SampleSet):
return data.run_date
def filter(self, filter_str, data):
for row in data:
row['string'] = [row['name'], row['confs'], row['groups'], str(row['run_date']), str(row['info'])]
keys = ['name', 'confs', 'groups', 'run_date', 'info']
self.create_filter_string(data, keys)
return filter(lambda row : vidjil_utils.advanced_filter(row['string'], filter_str), data)
def get_info_dict(self, data):
......
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