Skip to content

Commit

Permalink
feat(JAQPOT-325): add jaqpot internal id (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
alarv authored Sep 30, 2024
1 parent 72b51af commit 529e972
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { Chip } from '@nextui-org/chip';
import {
getDatasetStatusNode,
generateResultTableRow,
JAQPOT_INTERNAL_ID_KEY,
} from '@/app/util/dataset';
import { Button } from '@nextui-org/button';
import { ArrowDownTrayIcon, BugAntIcon } from '@heroicons/react/24/solid';
Expand Down Expand Up @@ -122,6 +123,7 @@ export default function DatasetResults({
dataset,
resultIndex,
result,
result[JAQPOT_INTERNAL_ID_KEY],
);
return (
<TableRow key={resultIndex}>
Expand Down
17 changes: 15 additions & 2 deletions src/app/util/dataset.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { Chip } from '@nextui-org/chip';
import React from 'react';
import { DatasetDto, FeatureDto, ModelDto } from '@/app/api.types';

export const JAQPOT_INTERNAL_ID_KEY = 'jaqpotInternalId';

export function getDatasetStatusNode(dataset: DatasetDto | null | undefined) {
if (!dataset) {
return <></>;
Expand All @@ -28,20 +30,31 @@ export function generateResultTableRow(
dataset: DatasetDto,
resultIndex: number,
result: any,
jaqpotInternalId?: string,
): string[] {
const independentFeatureCellValues: string[] = independentFeatures.map(
(feature, independentFeatureIndex) => {
const input = dataset.input[resultIndex] as any;
if (!input || !input[feature.key]) {
let input = dataset.input.find(
(inputRow) =>
jaqpotInternalId !== undefined &&
(inputRow as any)[JAQPOT_INTERNAL_ID_KEY] === jaqpotInternalId,
) as any;
if (!input) {
input = dataset.input[resultIndex];
}

if (!input) {
return 'N/A';
}

if (feature.featureType === 'CATEGORICAL') {
return (
feature.possibleValues?.find(
(possibleValue) => possibleValue.key === input[feature.key],
)?.value ?? input[feature.key]
);
}

return input[feature.key];
},
);
Expand Down

0 comments on commit 529e972

Please sign in to comment.