Skip to content

Commit

Permalink
fix preview
Browse files Browse the repository at this point in the history
  • Loading branch information
JulienMattiussi committed Oct 18, 2023
1 parent d724672 commit 76b32a3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
19 changes: 10 additions & 9 deletions src/api/services/precomputed/precomputed.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//TODO - Precomputing Task will be coded in next card

import ezs from '@ezs/core';
import progress from '../progress';
import localConfig from '../../../../config.json';
Expand Down Expand Up @@ -44,20 +46,19 @@ export const getPrecomputedDataPreview = async ctx => {
throw new Error(`Missing parameters`);
}

const commands = null;
const excerptLines = await ctx.dataset.getExcerpt(
sourceColumns ? { [sourceColumns]: { $ne: null } } : {},
sourceColumns && sourceColumns.length
? { [sourceColumns[0]]: { $ne: null } }
: {},
);
let result = [];
try {
for (let index = 0; index < excerptLines.length; index += BATCH_SIZE) {
let values = await processEzsEnrichment(
excerptLines.slice(index, index + BATCH_SIZE),
commands,
ctx,
true,
);
result.push(...values.map(v => v.value));
const entry = {};
sourceColumns.map(column => {
entry[column] = excerptLines[index][column];
});
result.push(entry);
}
} catch (error) {
const logger = getLogger(ctx.tenant);
Expand Down
2 changes: 2 additions & 0 deletions src/api/workers/precomputer.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//TODO - Precomputing Task will be coded in next card

import { CancelWorkerError } from '.';
import {
startEnrichment,
Expand Down
6 changes: 4 additions & 2 deletions src/app/js/admin/precomputed/PrecomputedPreview.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ const PrecomputedPreview = ({ lines, sourceColumns, p: polyglot }) => {
</Box>

<Box textAlign={'center'} mb={2}>
<Typography variant="body1">{sourceColumns}</Typography>
<Typography variant="body1">
{sourceColumns && sourceColumns.join(' | ')}
</Typography>
</Box>
<Box mb={4}>
{lines.length > 0 &&
Expand All @@ -47,7 +49,7 @@ const PrecomputedPreview = ({ lines, sourceColumns, p: polyglot }) => {
}}
title={JSON.stringify(line)}
>
{JSON.stringify(line)}
{Object.values(line).join(' | ')}
</Typography>
</Box>
))}
Expand Down

0 comments on commit 76b32a3

Please sign in to comment.