[Reporting] Improve language for error when CSV row total was indeterminable (#167843)

## Summary

Closes https://github.com/elastic/kibana/issues/153250
This commit is contained in:
Tim Sullivan 2023-10-04 19:30:45 -07:00 committed by GitHub
parent 99266280ff
commit e1d3cb9c14
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 891 additions and 872 deletions

View file

@ -1,71 +1,71 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`fields from job.columns (7.13+ generated) cells can be multi-value 1`] = `
exports[`CsvGenerator fields from job.columns (7.13+ generated) cells can be multi-value 1`] = `
"product,category
coconut,\\"cool, rad\\"
"
`;
exports[`fields from job.columns (7.13+ generated) columns can be top-level fields such as _id and _index 1`] = `
exports[`CsvGenerator fields from job.columns (7.13+ generated) columns can be top-level fields such as _id and _index 1`] = `
"\\"_id\\",\\"_index\\",product,category
\\"my-cool-id\\",\\"my-cool-index\\",coconut,\\"cool, rad\\"
"
`;
exports[`fields from job.columns (7.13+ generated) default column names come from tabify 1`] = `
exports[`CsvGenerator fields from job.columns (7.13+ generated) default column names come from tabify 1`] = `
"\\"_id\\",\\"_index\\",\\"_score\\",category,product
\\"my-cool-id\\",\\"my-cool-index\\",\\"'-\\",\\"cool, rad\\",coconut
"
`;
exports[`fields from job.searchSource.getFields() (7.12 generated) cells can be multi-value 1`] = `
exports[`CsvGenerator fields from job.searchSource.getFields() (7.12 generated) cells can be multi-value 1`] = `
"\\"_id\\",sku
\\"my-cool-id\\",\\"This is a cool SKU., This is also a cool SKU.\\"
"
`;
exports[`fields from job.searchSource.getFields() (7.12 generated) provides top-level underscored fields as columns 1`] = `
exports[`CsvGenerator fields from job.searchSource.getFields() (7.12 generated) provides top-level underscored fields as columns 1`] = `
"\\"_id\\",\\"_index\\",date,message
\\"my-cool-id\\",\\"my-cool-index\\",\\"2020-12-31T00:14:28.000Z\\",\\"it's nice to see you\\"
"
`;
exports[`fields from job.searchSource.getFields() (7.12 generated) sorts the fields when they are to be used as table column names 1`] = `
exports[`CsvGenerator fields from job.searchSource.getFields() (7.12 generated) sorts the fields when they are to be used as table column names 1`] = `
"\\"_id\\",\\"_index\\",\\"_score\\",date,\\"message_t\\",\\"message_u\\",\\"message_v\\",\\"message_w\\",\\"message_x\\",\\"message_y\\",\\"message_z\\"
\\"my-cool-id\\",\\"my-cool-index\\",\\"'-\\",\\"2020-12-31T00:14:28.000Z\\",\\"test field T\\",\\"test field U\\",\\"test field V\\",\\"test field W\\",\\"test field X\\",\\"test field Y\\",\\"test field Z\\"
"
`;
exports[`formats a search result to CSV content 1`] = `
exports[`CsvGenerator formats a search result to CSV content 1`] = `
"date,ip,message
\\"2020-12-31T00:14:28.000Z\\",\\"110.135.176.89\\",\\"This is a great message!\\"
"
`;
exports[`formats an empty search result to CSV content 1`] = `
exports[`CsvGenerator formats an empty search result to CSV content 1`] = `
"date,ip,message
"
`;
exports[`formulas can check for formulas, without escaping them 1`] = `
exports[`CsvGenerator formulas can check for formulas, without escaping them 1`] = `
"date,ip,message
\\"2020-12-31T00:14:28.000Z\\",\\"110.135.176.89\\",\\"=SUM(A1:A2)\\"
"
`;
exports[`formulas escapes formula values in a cell, doesn't warn the csv contains formulas 1`] = `
exports[`CsvGenerator formulas escapes formula values in a cell, doesn't warn the csv contains formulas 1`] = `
"date,ip,message
\\"2020-12-31T00:14:28.000Z\\",\\"110.135.176.89\\",\\"'=SUM(A1:A2)\\"
"
`;
exports[`formulas escapes formula values in a header, doesn't warn the csv contains formulas 1`] = `
exports[`CsvGenerator formulas escapes formula values in a header, doesn't warn the csv contains formulas 1`] = `
"date,ip,\\"'=SUM(A1:A2)\\"
\\"2020-12-31T00:14:28.000Z\\",\\"110.135.176.89\\",\\"This is great data\\"
"
`;
exports[`keeps order of the columns during the scroll 1`] = `
exports[`CsvGenerator keeps order of the columns during the scroll 1`] = `
"\\"_id\\",\\"_index\\",\\"_score\\",a,b
\\"'-\\",\\"'-\\",\\"'-\\",a1,b1
\\"'-\\",\\"'-\\",\\"'-\\",\\"'-\\",b2
@ -73,7 +73,7 @@ exports[`keeps order of the columns during the scroll 1`] = `
"
`;
exports[`uses the pit ID to page all the data 1`] = `
exports[`CsvGenerator uses the pit ID to page all the data 1`] = `
"date,ip,message
\\"2020-12-31T00:14:28.000Z\\",\\"110.135.176.89\\",\\"hit from the initial search\\"
\\"2020-12-31T00:14:28.000Z\\",\\"110.135.176.89\\",\\"hit from the initial search\\"
@ -178,7 +178,7 @@ exports[`uses the pit ID to page all the data 1`] = `
"
`;
exports[`warns if max size was reached 1`] = `
exports[`CsvGenerator warns if max size was reached 1`] = `
"date,ip,message
\\"2020-12-31T00:14:28.000Z\\",\\"110.135.176.89\\",\\"super cali fragile istic XPLA docious\\"
\\"2020-12-31T00:14:28.000Z\\",\\"110.135.176.89\\",\\"super cali fragile istic XPLA docious\\"

File diff suppressed because it is too large Load diff

View file

@ -475,9 +475,13 @@ export class CsvGenerator {
`ES scroll returned fewer total hits than expected! ` +
`Search result total hits: ${totalRecords}. Row count: ${this.csvRowCount}`
);
warnings.push(
i18nTexts.csvRowCountError({ expected: totalRecords ?? NaN, received: this.csvRowCount })
);
if (totalRecords || totalRecords === 0) {
warnings.push(
i18nTexts.csvRowCountError({ expected: totalRecords, received: this.csvRowCount })
);
} else {
warnings.push(i18nTexts.csvRowCountIndeterminable({ received: this.csvRowCount }));
}
}
return {

View file

@ -37,6 +37,12 @@ export const i18nTexts = {
'Encountered an error with the number of CSV rows generated from the search: expected {expected}, received {received}.',
values: { expected, received },
}),
csvRowCountIndeterminable: ({ received }: { expected?: number; received: number }) =>
i18n.translate('generateCsv.indeterminableRowCount', {
defaultMessage:
'Encountered an error with the number of CSV rows generated from the search: expected rows were indeterminable, received {received}.',
values: { received },
}),
csvUnableToClosePit: () =>
i18n.translate('generateCsv.csvUnableToClosePit', {
defaultMessage: