Commit 420bac15 authored by flothoni's avatar flothoni
Browse files

server; refactor function SampleSetList

parent 1d1138ae
Pipeline #201971 passed with stages
in 31 minutes and 15 seconds
......@@ -261,7 +261,7 @@ def all():
f = time.time()
listAllSamples = SampleSetList(helper, None, None, None, None, True)
log.debug("list loaded NONE(%.3fs)" % (time.time() - f))
log.debug("listAllSamples loaded (%.3fs)" % (time.time() - f))
return dict(query = result,
fields = fields,
......
......@@ -9,7 +9,8 @@ class SampleSetList():
s_table = db[self.type]
limitby = None
if page is not None and step is not None:
if page is not None and step is not None and getOnlyNumber == False:
limitby = (page*step, (page+1)*step+1) # one more element to indicate if another page exists
left = [db.sample_set_membership.on(s_table.sample_set_id == db.sample_set_membership.sample_set_id),
......@@ -44,6 +45,10 @@ class SampleSetList():
db.config.name.contains(search) |
db.auth_group.role.contains(search) |
db.auth_user.last_name.contains(search)))
select = [
s_table.id.with_alias('id')
]
if not getOnlyNumber:
# SQL string with GROUP_CONCAT queries
group_configs = get_conf_list_select()
......@@ -52,8 +57,7 @@ class SampleSetList():
group_group_names = get_group_names_select()
group_file_sizes = get_file_sizes_select()
select = [
s_table.id.with_alias('id'),
select += [
s_table.sample_set_id.with_alias('sample_set_id'),
s_table.info.with_alias('info'),
db.auth_user.last_name.with_alias('creator'),
......@@ -64,10 +68,12 @@ class SampleSetList():
group_config_names,
group_group_names
]
elif getOnlyNumber:
select = [
s_table.id.with_alias('id')
]
orderby = ~db[self.type].id
dedicated_fields = helper.get_dedicated_fields()
else:
orderby = None
dedicated_fields = []
if (tags is not None and len(tags) > 0):
query = filter_by_tags(query, self.type, tags)
......@@ -82,21 +88,11 @@ class SampleSetList():
join=join,
left=left,
limitby = limitby,
orderby = ~db[self.type].id,
orderby = orderby,
groupby = groupby + [db.tag_ref.record_id|db.tag_ref.table_name],
having = count >= len(tags),
cacheable=True
)
elif getOnlyNumber:
query_gss = db(
query
).select(
*select,
join=join,
left=left,
groupby = groupby,
cacheable=True
)
else:
query_gss = db(
query
......@@ -106,7 +102,7 @@ class SampleSetList():
left=left,
limitby = limitby,
groupby = groupby,
orderby = ~db[self.type].id,
orderby = orderby,
cacheable=True
)
......
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