Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions resources/queries/targetedms/InstrumentUtilizationByDay.query.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<query xmlns="http://labkey.org/data/xml/query">
<metadata>
<tables xmlns="http://labkey.org/data/xml">
<table tableName="InstrumentUtilizationByDay" tableDbType="TABLE">
<tableTitle>Runs by Day</tableTitle>
<columns>
<column columnName="AcquisitionDate">
<columnTitle>Date</columnTitle>
<formatString>Date</formatString>
</column>
<column columnName="RunCount">
<columnTitle>Runs</columnTitle>
</column>
<column columnName="FileCount">
<columnTitle>Files</columnTitle>
</column>
<column columnName="InstrumentNickname">
<columnTitle>Instrument</columnTitle>
</column>
</columns>
</table>
</tables>
</metadata>
</query>
23 changes: 23 additions & 0 deletions resources/queries/targetedms/InstrumentUtilizationByDay.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright (c) 2026 LabKey Corporation
*
* Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0
*/

-- Number of sample files and runs acquired per day, by instrument, across all folders the user can read.
-- Consumed by the instrument utilization calendar and the "Runs by Day" grid on the Show Instrument page.
SELECT
CAST(AcquisitionDay AS TIMESTAMP) AS AcquisitionDate,
COUNT(*) AS FileCount,
COUNT(DISTINCT RunId) AS RunCount,
InstrumentNickname
FROM
(SELECT
CAST(YEAR(AcquiredTime) AS VARCHAR) || '-' ||
(CASE WHEN MONTH(AcquiredTime) < 10 THEN '0' ELSE '' END) || CAST(MONTH(AcquiredTime) AS VARCHAR) || '-' ||
(CASE WHEN DAYOFMONTH(AcquiredTime) < 10 THEN '0' ELSE '' END) || CAST(DAYOFMONTH(AcquiredTime) AS VARCHAR) AS AcquisitionDay,
ReplicateId.RunId AS RunId,
InstrumentNickname
FROM targetedms.SampleFile
WHERE AcquiredTime IS NOT NULL) X
GROUP BY AcquisitionDay, InstrumentNickname
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<query xmlns="http://labkey.org/data/xml/query">
<metadata>
<tables xmlns="http://labkey.org/data/xml">
<table tableName="InstrumentUtilizationByMonth" tableDbType="TABLE">
<tableTitle>Runs by Month</tableTitle>
<columns>
<column columnName="MonthStart">
<columnTitle>Month</columnTitle>
<formatString>yyyy-MM</formatString>
</column>
<column columnName="RunCount">
<columnTitle>Runs</columnTitle>
</column>
<column columnName="FileCount">
<columnTitle>Files</columnTitle>
</column>
<column columnName="InstrumentNickname">
<columnTitle>Instrument</columnTitle>
</column>
</columns>
</table>
</tables>
</metadata>
</query>
22 changes: 22 additions & 0 deletions resources/queries/targetedms/InstrumentUtilizationByMonth.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright (c) 2026 LabKey Corporation
*
* Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0
*/

-- Number of sample files and runs acquired per month, by instrument, across all folders the user can read.
-- Consumed by the "Runs by Month" grid on the Show Instrument page.
SELECT
CAST(MonthStart || '-01' AS TIMESTAMP) AS MonthStart,
COUNT(*) AS FileCount,
COUNT(DISTINCT RunId) AS RunCount,
InstrumentNickname
FROM
(SELECT
CAST(YEAR(AcquiredTime) AS VARCHAR) || '-' ||
(CASE WHEN MONTH(AcquiredTime) < 10 THEN '0' ELSE '' END) || CAST(MONTH(AcquiredTime) AS VARCHAR) AS MonthStart,
ReplicateId.RunId AS RunId,
InstrumentNickname
FROM targetedms.SampleFile
WHERE AcquiredTime IS NOT NULL) X
GROUP BY MonthStart, InstrumentNickname
59 changes: 58 additions & 1 deletion src/org/labkey/targetedms/TargetedMSController.java
Original file line number Diff line number Diff line change
Expand Up @@ -4815,6 +4815,8 @@ public ShowInstrumentAction()
}

private static final String FOLDER_SUMMARY = "FolderSummary";
private static final String UTILIZATION_BY_DAY = "UtilizationByDay";
private static final String UTILIZATION_BY_MONTH = "UtilizationByMonth";

private InstrumentForm _form;

Expand Down Expand Up @@ -4846,11 +4848,29 @@ protected QueryView createQueryView(InstrumentForm form, BindException errors, b
TargetedMSSchema schema = new TargetedMSSchema(getUser(), getContainer());
return schema.createView(getViewContext(), settings, errors);
}
if (UTILIZATION_BY_DAY.equalsIgnoreCase(dataRegion))
{
QuerySettings settings = new QuerySettings(getViewContext(), UTILIZATION_BY_DAY, "InstrumentUtilizationByDay");
settings.setBaseSort(new Sort("-AcquisitionDate"));
settings.setBaseFilter(new SimpleFilter(FieldKey.fromParts("InstrumentNickname"), form.getName()));
settings.setContainerFilterName(ContainerFilter.Type.AllFolders.name());
TargetedMSSchema schema = new TargetedMSSchema(getUser(), getContainer());
return schema.createView(getViewContext(), settings, errors);
}
if (UTILIZATION_BY_MONTH.equalsIgnoreCase(dataRegion))
{
QuerySettings settings = new QuerySettings(getViewContext(), UTILIZATION_BY_MONTH, "InstrumentUtilizationByMonth");
settings.setBaseSort(new Sort("-MonthStart"));
settings.setBaseFilter(new SimpleFilter(FieldKey.fromParts("InstrumentNickname"), form.getName()));
settings.setContainerFilterName(ContainerFilter.Type.AllFolders.name());
TargetedMSSchema schema = new TargetedMSSchema(getUser(), getContainer());
return schema.createView(getViewContext(), settings, errors);
}
throw new NotFoundException("Unknown dataRegion: " + dataRegion);
}

@Override
public ModelAndView getView(InstrumentForm form, BindException errors)
public ModelAndView getView(InstrumentForm form, BindException errors) throws Exception
{
if (form.getName() == null)
{
Expand All @@ -4876,6 +4896,21 @@ public ModelAndView getView(InstrumentForm form, BindException errors)
result.addView(nameView);
}

var calendarView = new JspView<>("/org/labkey/targetedms/view/instrumentUtilizationCalendar.jsp", form.getName());
calendarView.setTitle("Utilization Calendar");
calendarView.setFrame(WebPartView.FrameType.PORTAL);
result.addView(calendarView);

QueryView byDayView = createInitializedQueryView(form, errors, false, UTILIZATION_BY_DAY);
byDayView.setFrame(WebPartView.FrameType.NONE);
QueryView byMonthView = createInitializedQueryView(form, errors, false, UTILIZATION_BY_MONTH);
byMonthView.setFrame(WebPartView.FrameType.NONE);

var utilizationView = new JspView<>("/org/labkey/targetedms/view/instrumentUtilizationGrids.jsp", new InstrumentUtilizationBean(byDayView, byMonthView));
utilizationView.setTitle("Runs Acquired");
utilizationView.setFrame(WebPartView.FrameType.PORTAL);
result.addView(utilizationView);

QueryView folderSummaryView = createQueryView(form, errors, false, FOLDER_SUMMARY);
folderSummaryView.setTitle("Summary by Folder");
folderSummaryView.setFrame(WebPartView.FrameType.PORTAL);
Expand All @@ -4891,6 +4926,28 @@ public ModelAndView getView(InstrumentForm form, BindException errors)
}
}

public static class InstrumentUtilizationBean
{
private final QueryView _byDayView;
private final QueryView _byMonthView;

public InstrumentUtilizationBean(QueryView byDayView, QueryView byMonthView)
{
_byDayView = byDayView;
_byMonthView = byMonthView;
}

public QueryView getByDayView()
{
return _byDayView;
}

public QueryView getByMonthView()
{
return _byMonthView;
}
}

@RequiresPermission(ReadPermission.class)
public class ShowReplicatesAction extends ShowRunSingleDetailsAction<RunDetailsForm>
{
Expand Down
Loading
Loading