Repository navigation
GitHub Issue 1708: persist sample dashboard and insights stats #8231
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
Merged
Merged
Changes from 12 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
7e05ef3
GitHub Issue 1708: persist sample dashboard and insights stats
XingY 09a2009
merge from develop
XingY 301c206
crlf
XingY 3063314
Use stats for sample type table sample count column
XingY 01c07cc
Use stats for sample type table sample count column
XingY 46609d2
CC review
XingY d202214
Merge remote-tracking branch 'origin/develop' into fb_sampleCount
XingY b7c0b50
Merge remote-tracking branch 'origin/develop' into fb_sampleCount
XingY 539b0d8
Code review changes
XingY 80d15ff
Merge remote-tracking branch 'origin/develop' into fb_sampleCount
XingY ec9f466
exception
XingY 03ffa74
Fix some RepeatedCommitTask warnings in tests
XingY 29b5473
Merge remote-tracking branch 'origin/develop' into fb_sampleCount
XingY 94daa10
Merge remote-tracking branch 'origin/develop' into fb_sampleCount
XingY a000438
Merge remote-tracking branch 'origin/develop' into fb_sampleCount
XingY fb6a453
Merge remote-tracking branch 'origin/develop' into fb_sampleCount
XingY aac9d83
Merge remote-tracking branch 'origin/develop' into fb_sampleCount
XingY 2029bba
Merge remote-tracking branch 'origin/develop' into fb_sampleCount
XingY File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| /* | ||
| * Copyright (c) 2026 LabKey Corporation | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.labkey.api.exp.api; | ||
|
|
||
| import org.jetbrains.annotations.NotNull; | ||
| import org.jetbrains.annotations.Nullable; | ||
| import org.labkey.api.data.ContainerFilter; | ||
| import org.labkey.api.data.DbSchema; | ||
| import org.labkey.api.data.SQLFragment; | ||
| import org.labkey.api.services.ServiceRegistry; | ||
|
|
||
| /** | ||
| * Serves sample counts that a module maintains ahead of time, so a caller can read them instead of counting samples. | ||
| * Registered by the module that owns those counts; null when no module does, in which case callers count live. | ||
| */ | ||
| public interface SampleCountsService | ||
| { | ||
| static void setInstance(SampleCountsService impl) | ||
| { | ||
| ServiceRegistry.get().registerService(SampleCountsService.class, impl); | ||
| } | ||
|
|
||
| @Nullable | ||
| static SampleCountsService get() | ||
| { | ||
| return ServiceRegistry.get().getService(SampleCountsService.class); | ||
| } | ||
|
|
||
| /** | ||
| * A scalar expression for how many samples a sample type has in the folders the container filter allows, suitable | ||
| * for a correlated subquery against a sample type table. | ||
| * | ||
| * @param sampleTypeRowId the enclosing query's sample type RowId column | ||
| * @param liveCount counts the samples directly; the returned expression falls back to it wherever the maintained | ||
| * counts can't answer, so a count that isn't ready is slow rather than wrong. An implementation | ||
| * may embed it more than once, and must append this fragment itself at each position rather than | ||
| * copying its SQL text, so that its bound parameters stay aligned with their placeholders. | ||
| * @return null when this service can't answer at all, leaving the caller to use liveCount | ||
| */ | ||
| @Nullable | ||
| SQLFragment getSampleCountSQL(@NotNull SQLFragment sampleTypeRowId, @NotNull ContainerFilter cf, | ||
| @NotNull DbSchema schema, @NotNull SQLFragment liveCount); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,6 +15,8 @@ | |
| */ | ||
| package org.labkey.assay; | ||
|
|
||
| import org.jetbrains.annotations.NotNull; | ||
| import org.labkey.api.data.AccumulatingCommitTask; | ||
| import org.labkey.api.data.Container; | ||
| import org.labkey.api.data.DbScope; | ||
| import org.labkey.api.data.DbScope.CommitTaskOption; | ||
|
|
@@ -26,16 +28,51 @@ | |
| import org.labkey.api.security.User; | ||
|
|
||
| import java.util.List; | ||
| import java.util.Set; | ||
|
|
||
| public class AssayExperimentListener implements ExperimentListener | ||
| { | ||
| /* | ||
| * Both deletes below fire once per item, so a folder delete reaches them once per batch or run it holds. Collecting | ||
| * the items and de-indexing them together keeps that to one commit task, which is also what the deindex calls want | ||
| * -- each resolves its items to document ids and deletes them in a single search request. | ||
| * | ||
| * Keyed by a constant rather than by container: a document id is not container-scoped, and taking no container is | ||
| * what lets these run after the container itself is gone. | ||
| */ | ||
|
|
||
| private static class DeindexAssayBatchesTask extends AccumulatingCommitTask<String, ExpExperiment> | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @labkey-jeckels I included some unrelated AccumulatingCommitTask switch in this branch to address the warnings logged while running tests. |
||
| { | ||
| private DeindexAssayBatchesTask() | ||
| { | ||
| super(DeindexAssayBatchesTask.class.getName()); | ||
| } | ||
|
|
||
| @Override | ||
| protected void process(@NotNull String key, @NotNull Set<ExpExperiment> batches) | ||
| { | ||
| AssayManager.get().deindexAssayBatches(batches); | ||
| } | ||
| } | ||
|
|
||
| private static class DeindexAssayRunsTask extends AccumulatingCommitTask<String, ExpRun> | ||
| { | ||
| private DeindexAssayRunsTask() | ||
| { | ||
| super(DeindexAssayRunsTask.class.getName()); | ||
| } | ||
|
|
||
| @Override | ||
| protected void process(@NotNull String key, @NotNull Set<ExpRun> runs) | ||
| { | ||
| AssayManager.get().deindexAssayRuns(runs); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public void afterExperimentDeleted(Container c, User user, ExpExperiment experiment) | ||
| { | ||
| DbScope.getLabKeyScope().addCommitTask(() -> | ||
| AssayManager.get().deindexAssayBatches(List.of(experiment)), | ||
| CommitTaskOption.POSTCOMMIT | ||
| ); | ||
| new DeindexAssayBatchesTask().register(DbScope.getLabKeyScope(), List.of(experiment), CommitTaskOption.POSTCOMMIT); | ||
| } | ||
|
|
||
| @Override | ||
|
|
@@ -47,10 +84,7 @@ public void afterExperimentSaved(Container c, User user, ExpExperiment experimen | |
| @Override | ||
| public void afterRunDelete(ExpProtocol protocol, ExpRun run, User user) | ||
| { | ||
| DbScope.getLabKeyScope().addCommitTask(() -> | ||
| AssayManager.get().deindexAssayRuns(List.of(run)), | ||
| CommitTaskOption.POSTCOMMIT | ||
| ); | ||
| new DeindexAssayRunsTask().register(DbScope.getLabKeyScope(), List.of(run), CommitTaskOption.POSTCOMMIT); | ||
| } | ||
|
|
||
| @Override | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.