Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
vidjil
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1,688
Issues
1,688
List
Boards
Labels
Service Desk
Milestones
Merge Requests
85
Merge Requests
85
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vidjil
vidjil
Commits
adcf7e89
Commit
adcf7e89
authored
Oct 21, 2020
by
Ryan Herbert
Committed by
Mikaël Salson
Nov 20, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SampleSetList: refactor some type-specific fields
Pass a helper instance to SampleSetList instead of a set type
parent
e7985084
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
58 additions
and
20 deletions
+58
-20
server/web2py/applications/vidjil/controllers/sample_set.py
server/web2py/applications/vidjil/controllers/sample_set.py
+4
-3
server/web2py/applications/vidjil/models/SampleSet.py
server/web2py/applications/vidjil/models/SampleSet.py
+8
-0
server/web2py/applications/vidjil/models/generic.py
server/web2py/applications/vidjil/models/generic.py
+10
-0
server/web2py/applications/vidjil/models/patient.py
server/web2py/applications/vidjil/models/patient.py
+12
-0
server/web2py/applications/vidjil/models/run.py
server/web2py/applications/vidjil/models/run.py
+11
-0
server/web2py/applications/vidjil/models/sample_set_list.py
server/web2py/applications/vidjil/models/sample_set_list.py
+13
-17
No files found.
server/web2py/applications/vidjil/controllers/sample_set.py
View file @
adcf7e89
...
@@ -222,16 +222,17 @@ def all():
...
@@ -222,16 +222,17 @@ def all():
search
,
tags
=
parse_search
(
request
.
vars
[
"filter"
])
search
,
tags
=
parse_search
(
request
.
vars
[
"filter"
])
group_ids
=
get_involved_groups
()
group_ids
=
get_involved_groups
()
factory
=
ModelFactory
()
helper
=
factory
.
get_instance
(
type
=
type
)
f
=
time
.
time
()
f
=
time
.
time
()
slist
=
SampleSetList
(
type
,
page
,
step
,
tags
)
slist
=
SampleSetList
(
helper
,
page
,
step
,
tags
)
# failsafe if filtered display all results
# failsafe if filtered display all results
step
=
len
(
slist
)
if
step
is
None
else
step
step
=
len
(
slist
)
if
step
is
None
else
step
page
=
0
if
page
is
None
else
page
page
=
0
if
page
is
None
else
page
result
=
slist
.
result
result
=
slist
.
result
factory
=
ModelFactory
()
helper
=
factory
.
get_instance
(
type
=
type
)
fields
=
helper
.
get_fields
()
fields
=
helper
.
get_fields
()
sort_fields
=
helper
.
get_sort_fields
()
sort_fields
=
helper
.
get_sort_fields
()
...
...
server/web2py/applications/vidjil/models/SampleSet.py
View file @
adcf7e89
...
@@ -158,6 +158,14 @@ class SampleSet(object):
...
@@ -158,6 +158,14 @@ class SampleSet(object):
def
validate
(
self
,
data
):
def
validate
(
self
,
data
):
pass
pass
@
abstractmethod
def
get_dedicated_fields
(
self
):
pass
@
abstractmethod
def
get_dedicated_group
(
self
):
pass
def
get_sample_name
(
sample_set_id
):
def
get_sample_name
(
sample_set_id
):
'''
'''
Return the name associated with a sample set (eg. a run or a
Return the name associated with a sample set (eg. a run or a
...
...
server/web2py/applications/vidjil/models/generic.py
View file @
adcf7e89
...
@@ -32,3 +32,13 @@ class Generic(SampleSet):
...
@@ -32,3 +32,13 @@ class Generic(SampleSet):
if
data
[
"name"
].
find
(
"|"
)
>=
0
:
if
data
[
"name"
].
find
(
"|"
)
>=
0
:
error
.
append
(
"illegal character '|' in name"
)
error
.
append
(
"illegal character '|' in name"
)
return
error
return
error
def
get_dedicated_fields
(
self
):
table
=
db
[
self
.
type
]
return
[
table
.
name
.
with_alias
(
'name'
)
]
def
get_dedicated_group
(
self
):
table
=
db
[
self
.
type
]
return
[
table
.
name
]
server/web2py/applications/vidjil/models/patient.py
View file @
adcf7e89
...
@@ -63,6 +63,18 @@ class Patient(SampleSet):
...
@@ -63,6 +63,18 @@ class Patient(SampleSet):
error
.
append
(
"illegal character '|' in name"
)
error
.
append
(
"illegal character '|' in name"
)
return
error
return
error
def
get_dedicated_fields
(
self
):
table
=
db
[
self
.
type
]
return
[
table
.
first_name
.
with_alias
(
'first_name'
),
table
.
last_name
.
with_alias
(
'last_name'
),
table
.
birth
.
with_alias
(
'birth'
),
]
def
get_dedicated_group
(
self
):
table
=
db
[
self
.
type
]
return
[
table
.
first_name
,
table
.
last_name
,
table
.
birth
]
def
get_name_filter_query
(
self
,
query
):
def
get_name_filter_query
(
self
,
query
):
if
query
is
None
or
query
==
''
:
if
query
is
None
or
query
==
''
:
return
(
db
[
self
.
type
].
id
>
0
)
return
(
db
[
self
.
type
].
id
>
0
)
...
...
server/web2py/applications/vidjil/models/run.py
View file @
adcf7e89
...
@@ -61,3 +61,14 @@ class Run(SampleSet):
...
@@ -61,3 +61,14 @@ class Run(SampleSet):
error
.
append
(
"illegal character '|' in name"
)
error
.
append
(
"illegal character '|' in name"
)
return
error
return
error
def
get_dedicated_fields
(
self
):
table
=
db
[
self
.
type
]
return
[
table
.
name
.
with_alias
(
'name'
),
table
.
run_date
.
with_alias
(
'run_date'
),
]
def
get_dedicated_group
(
self
):
table
=
db
[
self
.
type
]
return
[
table
.
name
]
server/web2py/applications/vidjil/models/sample_set_list.py
View file @
adcf7e89
...
@@ -4,9 +4,9 @@ class SampleSetList():
...
@@ -4,9 +4,9 @@ class SampleSetList():
This class is used to load all the required information for such a list.
This class is used to load all the required information for such a list.
'''
'''
def
__init__
(
self
,
type
,
page
=
None
,
step
=
None
,
tags
=
None
):
def
__init__
(
self
,
helper
,
page
=
None
,
step
=
None
,
tags
=
None
):
self
.
type
=
type
self
.
type
=
helper
.
get_type
()
s_table
=
db
[
type
]
s_table
=
db
[
self
.
type
]
limitby
=
None
limitby
=
None
if
page
is
not
None
and
step
is
not
None
:
if
page
is
not
None
and
step
is
not
None
:
...
@@ -16,7 +16,10 @@ class SampleSetList():
...
@@ -16,7 +16,10 @@ class SampleSetList():
db
.
sequence_file
.
on
(
db
.
sample_set_membership
.
sequence_file_id
==
db
.
sequence_file
.
id
),
db
.
sequence_file
.
on
(
db
.
sample_set_membership
.
sequence_file_id
==
db
.
sequence_file
.
id
),
db
.
fused_file
.
on
(
s_table
.
sample_set_id
==
db
.
fused_file
.
sample_set_id
),
db
.
fused_file
.
on
(
s_table
.
sample_set_id
==
db
.
fused_file
.
sample_set_id
),
db
.
config
.
on
(
db
.
fused_file
.
config_id
==
db
.
config
.
id
),
db
.
config
.
on
(
db
.
fused_file
.
config_id
==
db
.
config
.
id
),
db
.
auth_permission
.
on
((
db
.
auth_permission
.
table_name
==
'sample_set'
)
&
(
db
.
auth_permission
.
record_id
==
s_table
.
sample_set_id
)
&
(
db
.
auth_permission
.
name
==
PermissionEnum
.
access
.
value
)),
db
.
auth_permission
.
on
(
(
db
.
auth_permission
.
table_name
==
'sample_set'
)
&
(
db
.
auth_permission
.
record_id
==
s_table
.
sample_set_id
)
&
(
db
.
auth_permission
.
name
==
PermissionEnum
.
access
.
value
)),
db
.
auth_group
.
on
(
db
.
auth_permission
.
group_id
==
db
.
auth_group
.
id
),
db
.
auth_group
.
on
(
db
.
auth_permission
.
group_id
==
db
.
auth_group
.
id
),
db
.
auth_membership
.
on
(
db
.
auth_group
.
id
==
db
.
auth_membership
.
group_id
),
db
.
auth_membership
.
on
(
db
.
auth_group
.
id
==
db
.
auth_membership
.
group_id
),
db
.
auth_permission
.
with_alias
(
'anon_permission'
).
on
(
db
.
auth_permission
.
with_alias
(
'anon_permission'
).
on
(
...
@@ -33,17 +36,10 @@ class SampleSetList():
...
@@ -33,17 +36,10 @@ class SampleSetList():
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
()
# TODO remove this hack
dedicated_fields
=
helper
.
get_dedicated_fields
()
if
self
.
type
==
'patient'
:
dedicated_fields
=
[
groupby
=
[
s_table
.
id
,
s_table
.
sample_set_id
,
s_table
.
info
,
db
.
auth_user
.
last_name
]
s_table
.
first_name
.
with_alias
(
'first_name'
),
groupby
+=
helper
.
get_dedicated_group
()
s_table
.
last_name
.
with_alias
(
'last_name'
),
s_table
.
birth
.
with_alias
(
'birth'
),
]
groupby
=
[
s_table
.
id
,
s_table
.
sample_set_id
,
s_table
.
first_name
,
s_table
.
last_name
,
s_table
.
birth
,
s_table
.
info
,
db
.
auth_user
.
last_name
]
else
:
dedicated_fields
=
[
s_table
.
name
.
with_alias
(
'name'
)]
groupby
=
[
s_table
.
id
,
s_table
.
sample_set_id
,
s_table
.
name
,
s_table
.
info
,
db
.
auth_user
.
last_name
],
query
=
((
auth
.
vidjil_accessible_query
(
'read'
,
db
.
sample_set
))
&
query
=
((
auth
.
vidjil_accessible_query
(
'read'
,
db
.
sample_set
))
&
(
s_table
.
sample_set_id
==
db
.
sample_set
.
id
)
&
(
s_table
.
sample_set_id
==
db
.
sample_set
.
id
)
&
...
@@ -75,7 +71,7 @@ class SampleSetList():
...
@@ -75,7 +71,7 @@ class SampleSetList():
*
select
+
dedicated_fields
,
*
select
+
dedicated_fields
,
left
=
left
,
left
=
left
,
limitby
=
limitby
,
limitby
=
limitby
,
orderby
=
~
db
[
type
].
id
,
orderby
=
~
db
[
self
.
type
].
id
,
groupby
=
groupby
+
[
db
.
tag_ref
.
record_id
|
db
.
tag_ref
.
table_name
],
groupby
=
groupby
+
[
db
.
tag_ref
.
record_id
|
db
.
tag_ref
.
table_name
],
having
=
count
>=
len
(
tags
),
having
=
count
>=
len
(
tags
),
cacheable
=
True
cacheable
=
True
...
@@ -88,7 +84,7 @@ class SampleSetList():
...
@@ -88,7 +84,7 @@ class SampleSetList():
left
=
left
,
left
=
left
,
limitby
=
limitby
,
limitby
=
limitby
,
groupby
=
groupby
,
groupby
=
groupby
,
orderby
=
~
db
[
type
].
id
,
orderby
=
~
db
[
self
.
type
].
id
,
cacheable
=
True
cacheable
=
True
)
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment