Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CDS learn group page refactor #645

Merged
merged 11 commits into from
Feb 27, 2024
26 changes: 0 additions & 26 deletions resources/queries/cds/learn_groups.sql

This file was deleted.

59 changes: 20 additions & 39 deletions resources/queries/cds/learn_studiesforgroups.sql
Original file line number Diff line number Diff line change
@@ -1,42 +1,23 @@
SELECT DISTINCT
-- Query for studies with either product or assay data associated with it, used by the learn group store
-- to get the list of studies for the group summary pages

g.group_id,
g.study_label,
g.group_name,
group_concat(g.has_data) AS has_data, -- since LK SQL doesn't support boolean aggregate, going this route
g.study_name,
g.description
SELECT DISTINCT g.study_name,
g.study_label,
g.description,
g.has_data
FROM (SELECT s.study_name,
s.label AS study_label,
s.description,
CASE
WHEN (afs.has_data IS NULL AND pfs.has_data IS NULL) THEN false
WHEN (afs.has_data IS NULL) THEN pfs.has_data
WHEN (pfs.has_data IS NULL) THEN afs.has_data
ELSE (afs.has_data OR pfs.has_data)
END AS has_data

FROM
(SELECT DISTINCT
sgm.groupId.rowid AS group_id,
s.label AS study_label,
sgm.groupId.label AS group_name,
(CASE WHEN afs.has_data IS NULL OR pfs.has_data IS NULL THEN false ELSE (afs.has_data OR pfs.has_data) END) AS has_data,
s.study_name AS study_name,
s.description
FROM cds.study s
LEFT JOIN cds.learn_productsforstudies pfs
ON s.study_name = pfs.study_name
LEFT JOIN cds.learn_assaysforstudies afs ON s.study_name = afs.prot) g

FROM
study.subjectgroupmap sgm
LEFT JOIN study.subjectcategory sc ON sgm.groupId.CategoryId.RowId = sc.RowId
LEFT JOIN cds.study s ON sgm.container.name = s.study_name -- each study protocol has a container of the same name as the study protocol
LEFT JOIN cds.learn_productsforstudies pfs ON sgm.container.name = pfs.study_name
LEFT JOIN cds.learn_assaysforstudies afs ON sgm.container.name = afs.prot

WHERE sc.OwnerId IN (-1, userid()) -- Get Shared/Curated groups and Saved Groups created by the current user

GROUP BY
sgm.groupId.rowid,
s.label,
sgm.groupId.label,
afs.has_data,
pfs.has_data,
s.study_name,
s.description) g

GROUP BY
g.group_id,
g.study_label,
g.group_name,
g.study_name,
g.description
GROUP BY g.study_name, g.study_label, g.description, g.has_data
1 change: 0 additions & 1 deletion src/org/labkey/cds/view/template/ConnectorTemplate.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@
srcPath + "/model/InfoPaneMember.js",
srcPath + "/model/TimepointPane.js",
srcPath + "/model/Summary.js",
srcPath + "/model/Group.js",
srcPath + "/model/Grid.js",
srcPath + "/model/MabDetail.js",
srcPath + "/model/MabGrid.js",
Expand Down
1 change: 0 additions & 1 deletion webapp/Connector/extapp.lib.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
<script path="Connector/src/model/InfoPaneMember.js"/>
<script path="Connector/src/model/TimepointPane.js"/>
<script path="Connector/src/model/Summary.js"/>
<script path="Connector/src/model/Group.js"/>
<script path="Connector/src/model/Grid.js"/>
<script path="Connector/src/model/MabDetail.js"/>
<script path="Connector/src/model/MabGrid.js"/>
Expand Down
57 changes: 47 additions & 10 deletions webapp/Connector/src/app/model/Group.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,57 @@ Ext.define('Connector.app.model.Group', {

extend : 'Ext.data.Model',

idProperty: 'group_name',
idProperty: 'label',

labelProperty: 'group_name',
labelProperty: 'label',

resolvableField: 'group_name',
resolvableField: 'label',

fields: [
{name: 'group_name', sortType: 'asUCString'},
{name: 'group_type'},
{name: 'label', sortType: 'asUCString'},
{name: 'id'},
{name: 'rowid'},

// fields for the home page listing and group summary
{name: 'filters'},
{name: 'containsPlot', type: 'boolean', defaultValue: false, convert : function(value, partial) {
if (partial.raw){
if (partial.raw.type === 'mab')
return value;
var raw = partial.raw.filters;
var containsPlot = false;
if (Ext.isString(raw)) {
var filterArray = Connector.model.Filter.fromJSON(raw);
if (Ext.isArray(filterArray)) {
Ext.each(filterArray, function(filter) {
if (filter.isPlot === true) {
containsPlot = true;
}
});
}
}
return containsPlot;
}
}},
{name: 'categoryId'},
{name: 'shared', type: 'boolean', defaultValue: false, convert : function(value, partial) {
if (partial.raw){
if (partial.raw.type === 'mab')
return value;
return partial.raw.category.shared;
}
}},
{name: 'type'},
{name: 'participantIds', convert : Connector.model.Filter.asArray},
{name: 'modified', type: 'DATE'},
{name: 'isMab', type: 'Boolean'},
{name: 'group_id'},
{name: 'description'},
{name: 'description', convert : function(value, partial) {
if (partial.raw){
return partial.raw.description ? partial.raw.description : 'No description given.'
}
}},

// fields for the learn grid
{name: 'study_label'},
{name: 'studies', convert : Connector.model.Filter.asArray},
{name: 'studySpecies', convert : Connector.model.Filter.asArray},
Expand All @@ -28,15 +67,13 @@ Ext.define('Connector.app.model.Group', {
{name: 'products', convert : Connector.model.Filter.asArray},
{name: 'assay_identifier'},
{name: 'assays', convert : Connector.model.Filter.asArray},

{name: 'study_names', convert : Connector.model.Filter.asArray},
{name: 'product_names', convert : Connector.model.Filter.asArray},
{name: 'assay_names', convert : Connector.model.Filter.asArray},
{name: 'species_names', convert : Connector.model.Filter.asArray},

{name: 'study_names_to_sort_on'},
{name: 'product_to_sort_on'},
{name: 'species_to_sort_on'},
{name: 'assay_to_sort_on'},
{name: 'assay_to_sort_on'}
]
});
Loading