Commit b585d2e1 authored by Ryan Herbert's avatar Ryan Herbert Committed by Mikaël Salson

mysql trickiness for file sizes

parent ce025c5b
...@@ -77,10 +77,9 @@ class SampleSet(object): ...@@ -77,10 +77,9 @@ class SampleSet(object):
def get_files_values(self, data): def get_files_values(self, data):
key = get_file_sizes_select() key = get_file_sizes_select()
tmp = [] if data._extra[key] is None else data._extra[key].split(',') size = 0 if data._extra[key] is None else data._extra[key]
file_count = len(tmp) file_count = data.file_count
sizes = [int(s.split(';')[1]) for s in tmp] return file_count, size
return file_count, sum(sizes)
def get_files(self, data): def get_files(self, data):
file_count, size = self.get_files_values(data) file_count, size = self.get_files_values(data)
...@@ -229,4 +228,4 @@ def get_group_names_select(): ...@@ -229,4 +228,4 @@ def get_group_names_select():
return "GROUP_CONCAT(DISTINCT auth_group.role)" return "GROUP_CONCAT(DISTINCT auth_group.role)"
def get_file_sizes_select(): def get_file_sizes_select():
return "GROUP_CONCAT(DISTINCT (sequence_file.id || ';' || sequence_file.size_file))" return "COUNT(DISTINCT sequence_file.id) * SUM(sequence_file.size_file) / COUNT(*)"
...@@ -56,6 +56,7 @@ class SampleSetList(): ...@@ -56,6 +56,7 @@ class SampleSetList():
s_table.sample_set_id.with_alias('sample_set_id'), s_table.sample_set_id.with_alias('sample_set_id'),
s_table.info.with_alias('info'), s_table.info.with_alias('info'),
db.auth_user.last_name.with_alias('creator'), db.auth_user.last_name.with_alias('creator'),
db.sequence_file.id.count(True).with_alias('file_count'),
group_file_sizes, group_file_sizes,
group_configs, group_configs,
group_config_ids, group_config_ids,
......
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