Skip to content

Commit

Permalink
Merge branch 'release-deps' into dependabot/npm_and_yarn/sveltejs/kit…
Browse files Browse the repository at this point in the history
…-2.11.1
  • Loading branch information
JamesPeck authored Dec 19, 2024
2 parents 77354ce + d2cf110 commit deead31
Show file tree
Hide file tree
Showing 5 changed files with 141 additions and 110 deletions.
75 changes: 29 additions & 46 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"@skeletonlabs/skeleton": "2.10.3",
"@skeletonlabs/tw-plugin": "0.4.0",
"@sveltejs/adapter-auto": "^3.2.4",
"@sveltejs/adapter-node": "^2.1.2",
"@sveltejs/adapter-node": "^5.2.10",
"@sveltejs/kit": "^2.11.1",
"@sveltejs/vite-plugin-svelte": "^3.1.0",
"@tailwindcss/forms": "0.5.7",
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/datatable/accessories/Rows.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { DataHandler as RemoteHander } from '@vincjo/datatables/remote';
export let handler: DataHandler | RemoteHander;
export let options: number[] = [5, 10, 20, 50];
const rowsPerPage = handler.getRowsPerPage();
$: rowsPerPage = handler.getRowsPerPage();
const setRowsPerPage = () => {
handler.setPage(1);
if (handler instanceof RemoteHander) {
Expand Down
161 changes: 102 additions & 59 deletions src/lib/components/explorer/export/ExportStepper.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import { branding, features, settings, resources } from '$lib/configuration';
import { searchDictionary } from '$lib/services/dictionary';
import type { ExportInterface } from '$lib/models/Export';
import { onMount } from 'svelte';
export let query: QueryRequestInterface;
export let showTreeStep = false;
export let rows: ExportRowInterface[] = [];
Expand All @@ -42,6 +43,7 @@
let sampleIds = false;
let lastExports: ExportRowInterface[] = [];
let loadingSampleIds = false;
let checkingSampleIds = false;
$: datasetId = '';
$: canDownload = true;
$: apiExport = false;
Expand All @@ -51,6 +53,39 @@
{ dataElement: 'type', label: 'Type', sort: true },
];
onMount(async () => {
const exportedSampleIds = $exports.filter((e: ExportInterface) =>
e.conceptPath.includes('SAMPLE_ID'),
);
if (exportedSampleIds.length > 0) {
checkingSampleIds = true;
const genomicConcepts = await getGenomicConcepts();
if (genomicConcepts.length > 0) {
// Find sample IDs that match genomic concepts
const matchingSampleIds = exportedSampleIds.filter((sampleId) =>
genomicConcepts.some((concept) => concept.conceptPath === sampleId.conceptPath),
);
sampleIds = matchingSampleIds.length === genomicConcepts.length;
checkingSampleIds = false;
if (sampleIds) {
lastExports = matchingSampleIds.map((item) => ({
ref: item,
variableId: item.conceptPath,
variableName: item.display,
description: item.searchResult?.description,
type: item.searchResult?.type,
selected: true,
})) as ExportRowInterface[];
}
} else {
sampleIds = false;
checkingSampleIds = false;
}
} else {
sampleIds = false;
}
});
const MAX_DATA_POINTS_FOR_EXPORT = settings.maxDataPointsForExport || 1000000;
function openConfirmationModal() {
Expand Down Expand Up @@ -209,6 +244,40 @@
return totalDataPoints > MAX_DATA_POINTS_FOR_EXPORT;
}
async function getGenomicConcepts() {
const concepts = await searchDictionary(
'',
[
{
name: 'data_source_genomic',
category: 'data_source',
display: 'Genomic',
description: 'Associated with genomic data',
count: 0,
},
],
{ pageNumber: 0, pageSize: 10000 },
);
if (concepts.content.length === 0) {
return [];
}
// Get sample ID counts via cross counts query
const crossCountQuery = new Query(structuredClone(query.query));
crossCountQuery.expectedResultType = 'CROSS_COUNT';
const crossCountFields = concepts.content.map((concept) => concept.conceptPath);
crossCountQuery.setCrossCountFields(crossCountFields);
const crossCountResponse: Record<string, number> = await api.post('picsure/query/sync', {
query: crossCountQuery,
resourceUUID: resources.hpds,
});
// Filter and return only concepts with counts > 0
return concepts.content.filter((concept) => crossCountResponse[concept.conceptPath] > 0);
}
async function toggleSampleIds() {
try {
loadingSampleIds = true;
Expand All @@ -217,72 +286,42 @@
(e) => e.ref,
) as ExportInterface[];
removeExports(exportsToRemove || []);
rows = rows.filter((r) => !lastExports.includes(r));
rows = rows.filter((r) => !lastExports.some((le) => le.variableId === r.variableId));
return;
}
// Get genomic concepts from dictionary
const concepts = await searchDictionary(
'',
[
{
name: 'data_source_genomic',
category: 'data_source',
display: 'Genomic',
description: 'Associated with genomic data',
count: 0,
},
],
{ pageNumber: 0, pageSize: 10000 },
);
if (concepts.content.length === 0) {
return;
}
// Get sample ID counts via cross counts query
const crossCountQuery = new Query(structuredClone(query.query));
crossCountQuery.expectedResultType = 'CROSS_COUNT';
const crossCountFields = concepts.content.map((concept) => concept.conceptPath);
crossCountQuery.setCrossCountFields(crossCountFields);
const crossCountResponse: Record<string, number> = await api.post('picsure/query/sync', {
query: crossCountQuery,
resourceUUID: resources.hpds,
});
// Filter to paths with counts > 0
const conceptPathsToAdd = Object.entries(crossCountResponse)
// eslint-disable-next-line @typescript-eslint/no-unused-vars
.filter(([_, count]) => count > 0)
.map(([path]) => path);
const genomicConcepts = await getGenomicConcepts();
// Create new exports for each path
const newExports = conceptPathsToAdd.map((path) => {
const concept = concepts.content.find((c) => c.conceptPath === path);
return {
id: uuidv4(),
searchResult: concept,
display: concept?.display || '',
conceptPath: concept?.conceptPath || '',
} as ExportInterface;
});
// Create new exports for each concept
const newExports = genomicConcepts.map(
(concept) =>
({
id: uuidv4(),
searchResult: concept,
display: concept?.display || '',
conceptPath: concept?.conceptPath || '',
}) as ExportInterface,
);
// Add exports and create corresponding rows
addExports(newExports);
const newRows = newExports.map(
(e) =>
({
ref: e,
variableId: e.id,
variableName: e.display,
variableId: e?.searchResult?.conceptPath,
variableName: e?.display,
description: e?.searchResult?.description,
type: e?.searchResult.type,
type: e?.searchResult?.type,
selected: true,
}) as ExportRowInterface,
);
rows = [...rows, ...newRows];
//Remove duplicates
rows = Array.from(
[...rows, ...newRows]
.reduce((map, row) => map.set(row.variableId, row), new Map())
.values(),
);
lastExports = newRows;
} catch (error) {
console.error('Error in toggleSampleIds', error);
Expand Down Expand Up @@ -357,14 +396,18 @@
class="flex items-center"
data-testid="sample-ids-label"
>
<input
type="checkbox"
class="mr-1 &[aria-disabled=“true”]:opacity-75"
data-testid="sample-ids-checkbox"
id="sample-ids-checkbox"
bind:checked={sampleIds}
on:change={toggleSampleIds}
/>
{#if checkingSampleIds}
<ProgressRadial width="w-4" />
{:else}
<input
type="checkbox"
class="mr-1 &[aria-disabled=“true”]:opacity-75"
data-testid="sample-ids-checkbox"
id="sample-ids-checkbox"
bind:checked={sampleIds}
on:change={toggleSampleIds}
/>
{/if}
<span>Include sample identifiers</span>
</label>
</div>
Expand Down
11 changes: 8 additions & 3 deletions src/lib/stores/Export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const exports: Writable<ExportInterface[]> = writable([]);

function addExport(exportedField: ExportInterface) {
const currentExports = get(exports);
if (currentExports.some((e: ExportInterface) => e.id === exportedField.id)) {
if (currentExports.some((e: ExportInterface) => e.conceptPath === exportedField.conceptPath)) {
return;
}
exports.set([...currentExports, exportedField]);
Expand All @@ -16,7 +16,8 @@ function addExport(exportedField: ExportInterface) {
function addExports(exportedFields: ExportInterface[]) {
const currentExports = get(exports);
const newExports = exportedFields.filter(
(e: ExportInterface) => !currentExports.some((ce: ExportInterface) => ce.id === e.id),
(e: ExportInterface) =>
!currentExports.some((ce: ExportInterface) => ce.conceptPath === e.conceptPath),
);
exports.set([...currentExports, ...newExports]);
}
Expand All @@ -32,7 +33,11 @@ function removeExport(uuid: string) {

function removeExports(exportsToRemove: ExportInterface[]) {
const currentExports = get(exports);
exports.set(currentExports.filter((e: ExportInterface) => !exportsToRemove.includes(e)));
exports.set(
currentExports.filter(
(e: ExportInterface) => !exportsToRemove.some((re) => re.conceptPath === e.conceptPath),
),
);
}

export function clearExports() {
Expand Down

0 comments on commit deead31

Please sign in to comment.