Skip to content

Commit

Permalink
Show summary stats on homepage (#4952)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nelliney authored Jul 29, 2024
1 parent 9ca3198 commit 895d50f
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 7 deletions.
8 changes: 8 additions & 0 deletions src/shared/components/query/QueryStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1170,6 +1170,10 @@ export class QueryStore {
return _.sumBy(this.selectableSelectedStudies, s => s.allSampleCount);
}

@computed get sampleCountForAllStudies() {
return _.sumBy(this.selectableStudies, s => s.allSampleCount);
}

readonly sampleLists = remoteData<SampleList[]>({
invoke: async () => {
if (!this.isSingleNonVirtualStudySelected) {
Expand Down Expand Up @@ -1578,6 +1582,10 @@ export class QueryStore {
.filter(_.identity);
}

@computed get selectableStudies() {
return Array.from(this.treeData.map_studyId_cancerStudy.values());
}

public isVirtualStudy(studyId: string): boolean {
// if the study id doesn't correspond to one in this.cancerStudies, then its a virtual Study
return !this.cancerStudyIdsSet.result[studyId];
Expand Down
43 changes: 36 additions & 7 deletions src/shared/components/query/StudySelectorStats.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ export const StudySelectorStats: React.FunctionComponent<{
let numSelectedStudies = expr(
() => props.store.selectableSelectedStudyIds.length
);
let numAllStudies = expr(
() => props.store.selectableStudies.length
);

return (
<>
<a
Expand All @@ -27,13 +31,38 @@ export const StudySelectorStats: React.FunctionComponent<{
.store.showSelectedStudiesOnly;
}}
>
<b>{numSelectedStudies}</b>{' '}
{numSelectedStudies === 1 ? 'study' : 'studies'}{' '}
selected (
<b>
{props.store.sampleCountForSelectedStudies}
</b>{' '}
samples)
{props.store.selectableSelectedStudies.length ==
0 && (
<div>
<b>{numAllStudies}</b> studies available
(
<b>
{
props.store
.sampleCountForAllStudies
}
</b>{' '}
samples)
</div>
)}

{props.store.selectableSelectedStudies.length >
0 && (
<div>
<b>{numSelectedStudies}</b>{' '}
{numSelectedStudies === 1
? 'study'
: 'studies'}{' '}
selected (
<b>
{
props.store
.sampleCountForSelectedStudies
}
</b>{' '}
samples)
</div>
)}
</a>
{props.store.selectableSelectedStudies.length >
0 && (
Expand Down

0 comments on commit 895d50f

Please sign in to comment.