Skip to content
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

fix: ensure BATCH_SIZE is a Number #1800

Merged
merged 2 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/api/services/enrichment/enrichment.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ const getSourceData = async (ctx, sourceColumn) => {
};

export const createEnrichmentRule = async (ctx, enrichment) => {
const { enrichmentBatchSize: BATCH_SIZE = 10 } = ctx.configTenant;
const { enrichmentBatchSize } = ctx.configTenant;
const BATCH_SIZE = Number(enrichmentBatchSize || 10);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's right only because an enrichmentBatchSize of 0 makes no sense.

if (enrichment.advancedMode) {
return enrichment;
}
Expand All @@ -67,7 +68,8 @@ const cleanWebServiceRule = rule => {
};

export const getEnrichmentDataPreview = async ctx => {
const { enrichmentBatchSize: BATCH_SIZE = 10 } = ctx.configTenant;
const { enrichmentBatchSize } = ctx.configTenant;
const BATCH_SIZE = Number(enrichmentBatchSize || 10);
const { sourceColumn, subPath, rule } = ctx.request.body;
let previewRule = rule;
if (!sourceColumn && !rule) {
Expand Down Expand Up @@ -223,7 +225,8 @@ const processEzsEnrichment = (entries, commands, ctx, preview = false) => {
};

export const processEnrichment = async (enrichment, ctx) => {
const { enrichmentBatchSize: BATCH_SIZE = 10 } = ctx.configTenant;
const { enrichmentBatchSize } = ctx.configTenant;
const BATCH_SIZE = Number(enrichmentBatchSize || 10);
await ctx.enrichment.updateStatus(enrichment._id, IN_PROGRESS);
let errorCount = 0;

Expand Down
3 changes: 2 additions & 1 deletion src/app/js/admin/configTenant/ConfigTenantForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,10 @@ export const ConfigTenantForm = ({
<TextField
label="Enrichment Batch Size"
value={enrichmentBatchSize || ''}
type="number"
sx={{ mb: 2 }}
onChange={event => {
setEnrichmentBatchSize(event.target.value);
setEnrichmentBatchSize(Number(event.target.value));
}}
/>
<Box sx={{ mb: 10 }}>
Expand Down