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

SampleSetList fix file size counting

parent 05931d1e
...@@ -75,9 +75,15 @@ class SampleSet(object): ...@@ -75,9 +75,15 @@ class SampleSet(object):
def get_creator(self, data): def get_creator(self, data):
return data['creator'] return data['creator']
def get_files_values(self, data):
key = get_file_sizes_select()
tmp = [] if data._extra[key] is None else data._extra[key].split(',')
file_count = len(tmp)
sizes = [int(s.split(';')[1]) for s in tmp]
return file_count, sum(sizes)
def get_files(self, data): def get_files(self, data):
size = 0 if data['size'] is None else data['size'] file_count, size = self.get_files_values(data)
file_count = 0 if data['file_count'] is None else data['file_count']
return '%d (%s)' % (file_count, vidjil_utils.format_size(size)) return '%d (%s)' % (file_count, vidjil_utils.format_size(size))
def get_fields(self): def get_fields(self):
...@@ -221,3 +227,6 @@ def get_config_names_select(): ...@@ -221,3 +227,6 @@ def get_config_names_select():
def get_group_names_select(): def get_group_names_select():
return "GROUP_CONCAT(DISTINCT auth_group.role)" return "GROUP_CONCAT(DISTINCT auth_group.role)"
def get_file_sizes_select():
return "GROUP_CONCAT(DISTINCT CONCAT(sequence_file.id, ';', sequence_file.size_file))"
...@@ -42,6 +42,7 @@ class SampleSetList(): ...@@ -42,6 +42,7 @@ class SampleSetList():
group_config_ids = get_config_ids_select() group_config_ids = get_config_ids_select()
group_config_names = get_config_names_select() group_config_names = get_config_names_select()
group_group_names = get_group_names_select() group_group_names = get_group_names_select()
group_file_sizes = get_file_sizes_select()
dedicated_fields = helper.get_dedicated_fields() dedicated_fields = helper.get_dedicated_fields()
...@@ -65,8 +66,7 @@ class SampleSetList(): ...@@ -65,8 +66,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.size_file.sum().with_alias('size'), group_file_sizes,
db.sequence_file.id.count(distinct=True).with_alias('file_count'),
db.anon_permission.name.with_alias('has_permission'), db.anon_permission.name.with_alias('has_permission'),
group_configs, group_configs,
group_config_ids, group_config_ids,
......
...@@ -45,8 +45,7 @@ ...@@ -45,8 +45,7 @@
{{= field['call'](data)}} {{= field['call'](data)}}
</td> </td>
{{ pass }} {{ pass }}
{{ file_count = 0 if data.file_count is None else data.file_count }} {{ file_count, size = helper.get_files_values(data) }}
{{ size = 0 if data.size is None else data.size }}
{{ total_file_count += file_count ; total_size += size }} {{ total_file_count += file_count ; total_size += size }}
{{if isAdmin:}} <td onclick="db.call('sample_set/permission', {'id' :'{{=data.sample_set_id}}'} )" > <i class="icon-key" title="set permissions"></i> </td> {{else:}} <td></td> {{pass}} {{if isAdmin:}} <td onclick="db.call('sample_set/permission', {'id' :'{{=data.sample_set_id}}'} )" > <i class="icon-key" title="set permissions"></i> </td> {{else:}} <td></td> {{pass}}
......
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