Skip to content

Commit 1626c0c

Browse files
authored
metrics for file type fields in assays and datasets (#7003)
1 parent 68e3569 commit 1626c0c

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

experiment/src/org/labkey/experiment/ExperimentModule.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,20 @@ WHERE op.propertyid IN (
630630
assayMetrics.put("standardAssayRunsWithPlateTemplate", new SqlSelector(schema, new SQLFragment(runsWithPlateSQL).add("PlateTemplate").add("PlateTemplate")).getObject(Long.class));
631631
assayMetrics.put("standardAssayRunsWithPlateSet", new SqlSelector(schema, new SQLFragment(runsWithPlateSQL).add("PlateSet").add("PlateSet")).getObject(Long.class));
632632

633+
assayMetrics.put("assayRunsFileColumnCount", new SqlSelector(schema, """
634+
SELECT COUNT(DISTINCT DD.DomainURI) FROM
635+
exp.PropertyDescriptor D\s
636+
JOIN exp.PropertyDomain PD ON D.propertyId = PD.propertyid
637+
JOIN exp.DomainDescriptor DD on PD.domainID = DD.domainId
638+
WHERE DD.domainUri LIKE ? AND D.rangeURI = ?""", "urn:lsid:%:" + ExpProtocol.AssayDomainTypes.Run.getPrefix() + ".%", PropertyType.FILE_LINK.getTypeUri()).getObject(Long.class));
639+
640+
assayMetrics.put("assayResultsFileColumnCount", new SqlSelector(schema, """
641+
SELECT COUNT(DISTINCT DD.DomainURI) FROM
642+
exp.PropertyDescriptor D\s
643+
JOIN exp.PropertyDomain PD ON D.propertyId = PD.propertyid
644+
JOIN exp.DomainDescriptor DD on PD.domainID = DD.domainId
645+
WHERE DD.domainUri LIKE ? AND D.rangeURI = ?""", "urn:lsid:%:" + ExpProtocol.AssayDomainTypes.Result.getPrefix() + ".%", PropertyType.FILE_LINK.getTypeUri()).getObject(Long.class));
646+
633647
Map<String, Object> sampleLookupCountMetrics = new HashMap<>();
634648
SQLFragment baseAssaySampleLookupSQL = new SQLFragment("SELECT COUNT(*) FROM exp.propertydescriptor WHERE (lookupschema = 'samples' OR (lookupschema = 'exp' AND lookupquery = 'Materials')) AND propertyuri LIKE ?");
635649

study/src/org/labkey/study/StudyModule.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import org.labkey.api.data.dialect.SqlDialect;
3636
import org.labkey.api.data.views.DataViewService;
3737
import org.labkey.api.exp.LsidManager;
38+
import org.labkey.api.exp.PropertyType;
3839
import org.labkey.api.exp.api.ExperimentService;
3940
import org.labkey.api.exp.property.PropertyService;
4041
import org.labkey.api.files.FileContentService;
@@ -458,6 +459,13 @@ protected void startupAfterSpringConfig(ModuleContext moduleContext)
458459
metric.put("participantIdMappingCount", new SqlSelector(StudySchema.getInstance().getSchema(), "SELECT COUNT(DISTINCT container) FROM study.Participant WHERE AlternateId IS NOT NULL").getObject(Long.class));
459460
metric.put("participantAliasCount", new SqlSelector(StudySchema.getInstance().getSchema(), "SELECT COUNT(*) FROM study.Study WHERE ParticipantAliasDatasetId IS NOT NULL").getObject(Long.class));
460461

462+
metric.put("datasetsWithFileColumnCount", new SqlSelector(StudySchema.getInstance().getSchema(), """
463+
SELECT COUNT(DISTINCT DD.DomainURI) FROM
464+
exp.PropertyDescriptor D\s
465+
JOIN exp.PropertyDomain PD ON D.propertyId = PD.propertyid
466+
JOIN exp.DomainDescriptor DD on PD.domainID = DD.domainId
467+
WHERE DD.storageSchemaName = ? AND D.rangeURI = ?""", StudySchema.getInstance().getDatasetSchemaName(), PropertyType.FILE_LINK.getTypeUri()).getObject(Long.class));
468+
461469
// grab the counts of report and dataset notification settings (by notification option)
462470
Collection<? extends StudyImpl> allStudies = StudyManager.getInstance().getAllStudies();
463471
Map<ReportContentEmailManager.NotifyOption, Integer> notifyOptionCounts = new HashMap<>();

0 commit comments

Comments
 (0)