From a7209957c7b5ff638ed4c28d12d0e9f9a442f872 Mon Sep 17 00:00:00 2001 From: Joan Gallego Girona Date: Fri, 11 Oct 2024 10:33:44 +0200 Subject: [PATCH 1/3] csv with dots on the header text now work properly (#7341) --- app/api/csv/csv.ts | 2 +- app/api/csv/specs/__snapshots__/importFile.spec.ts.snap | 8 ++++---- app/api/csv/specs/csvLoader.spec.js | 1 + app/api/csv/specs/csvLoaderFixtures.ts | 5 +++++ app/api/csv/specs/test.csv | 8 ++++---- package.json | 2 +- 6 files changed, 16 insertions(+), 10 deletions(-) diff --git a/app/api/csv/csv.ts b/app/api/csv/csv.ts index 6e0662a1e5..64effd2dd7 100644 --- a/app/api/csv/csv.ts +++ b/app/api/csv/csv.ts @@ -58,7 +58,7 @@ const csv = (readStream: Readable, stopOnError = false) => ({ async read() { this.reading = true; - return csvtojson({ delimiter: DELIMITERS }) + return csvtojson({ delimiter: DELIMITERS, flatKeys: true }) .fromStream(readStream) .subscribe(async (row: CSVRow, index) => { if (!this.reading) { diff --git a/app/api/csv/specs/__snapshots__/importFile.spec.ts.snap b/app/api/csv/specs/__snapshots__/importFile.spec.ts.snap index 43784c62a2..1c10714d15 100644 --- a/app/api/csv/specs/__snapshots__/importFile.spec.ts.snap +++ b/app/api/csv/specs/__snapshots__/importFile.spec.ts.snap @@ -1,11 +1,11 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`importFile readStream should return a readable stream for the csv file 1`] = ` -"Title , text label , numeric label, non configured, select_label, not defined type, geolocation_geolocation,auto id, additional tag(s), Multi Select Label, Date label, Language +"Title , header.with.dots, text label , numeric label, non configured, select_label, not defined type, geolocation_geolocation,auto id, additional tag(s), Multi Select Label, Date label, Language -title1, text value 1, 1977, ______________, thesauri1 , notType1 , 1|1,,tag1, multivalue1,03/01/2022,English -title2, text value 2, 2019, ______________, thesauri2 , notType2 , ,,tag2, multivalue2,01/03/2022,Spanish -title3, text value 3, 2020, ______________, thesauri2 , notType3 , 0|0,,tag3, multivalue1|multivalue3,01/01/2022,AnyStringIsGood +title1, header with dots value 1, text value 1, 1977, ______________, thesauri1 , notType1 , 1|1,,tag1, multivalue1,03/01/2022,English +title2, header with dots value 2, text value 2, 2019, ______________, thesauri2 , notType2 , ,,tag2, multivalue2,01/03/2022,Spanish +title3, header with dots value 3, text value 3, 2020, ______________, thesauri2 , notType3 , 0|0,,tag3, multivalue1|multivalue3,01/01/2022,AnyStringIsGood " `; diff --git a/app/api/csv/specs/csvLoader.spec.js b/app/api/csv/specs/csvLoader.spec.js index c13d39f1d2..7742e94ce3 100644 --- a/app/api/csv/specs/csvLoader.spec.js +++ b/app/api/csv/specs/csvLoader.spec.js @@ -169,6 +169,7 @@ describe('csvLoader', () => { numeric_label: [{ value: 1977 }], select_label: [{ label: 'thesauri1', value: expect.any(String) }], text_label: [{ value: 'text value 1' }], + header_with_dots: [{ value: 'header with dots value 1' }], }); }); diff --git a/app/api/csv/specs/csvLoaderFixtures.ts b/app/api/csv/specs/csvLoaderFixtures.ts index 42242b8922..3cf4d2a95e 100644 --- a/app/api/csv/specs/csvLoaderFixtures.ts +++ b/app/api/csv/specs/csvLoaderFixtures.ts @@ -62,6 +62,11 @@ export default { label: 'text label', name: templateUtils.safeName('text label'), }, + { + type: propertyTypes.text, + label: 'header.with. dots', + name: templateUtils.safeName('header.with.dots'), + }, { type: propertyTypes.numeric, label: 'numeric label', diff --git a/app/api/csv/specs/test.csv b/app/api/csv/specs/test.csv index 59765b22f6..1ebae0ee4d 100644 --- a/app/api/csv/specs/test.csv +++ b/app/api/csv/specs/test.csv @@ -1,5 +1,5 @@ -Title , text label , numeric label, non configured, select_label, not defined type, geolocation_geolocation,auto id, additional tag(s), Multi Select Label, Date label, Language +Title , header.with.dots, text label , numeric label, non configured, select_label, not defined type, geolocation_geolocation,auto id, additional tag(s), Multi Select Label, Date label, Language -title1, text value 1, 1977, ______________, thesauri1 , notType1 , 1|1,,tag1, multivalue1,03/01/2022,English -title2, text value 2, 2019, ______________, thesauri2 , notType2 , ,,tag2, multivalue2,01/03/2022,Spanish -title3, text value 3, 2020, ______________, thesauri2 , notType3 , 0|0,,tag3, multivalue1|multivalue3,01/01/2022,AnyStringIsGood +title1, header with dots value 1, text value 1, 1977, ______________, thesauri1 , notType1 , 1|1,,tag1, multivalue1,03/01/2022,English +title2, header with dots value 2, text value 2, 2019, ______________, thesauri2 , notType2 , ,,tag2, multivalue2,01/03/2022,Spanish +title3, header with dots value 3, text value 3, 2020, ______________, thesauri2 , notType3 , 0|0,,tag3, multivalue1|multivalue3,01/01/2022,AnyStringIsGood diff --git a/package.json b/package.json index 3934d3fbad..ec87d864eb 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "hot-e2e": "DATABASE_NAME=uwazi_e2e INDEX_NAME=uwazi_e2e EXTERNAL_SERVICES=true yarn hot", "run-e2e": "DATABASE_NAME=uwazi_e2e INDEX_NAME=uwazi_e2e EXTERNAL_SERVICES=true yarn run-production", "hot-inspect": "export HOT=true; export BABEL_ENV=debug; yarn run watch-types & yarn dev-server --inspect & yarn run webpack-server", - "hot-debug": "export HOT=true; export BABEL_ENV=debug; node --no-experimental-fetch --inspect-brk=9229 server.js", + "hot-debug": "export HOT=true; export BABEL_ENV=debug; node --no-experimental-fetch --inspect-brk=9229 server.js & yarn run webpack-server", "reindex": "node scripts/run.js ../database/reindex_elastic.js", "import-csv": "node --no-experimental-fetch scripts/run.js ../database/import_csv.js", "blank-state": "node --no-experimental-fetch scripts/bash.js ./database/blank_state.sh", From 2b3230694caf526ce22e75e85f8ff72d22d7a963 Mon Sep 17 00:00:00 2001 From: Daneryl Date: Fri, 11 Oct 2024 10:33:50 +0200 Subject: [PATCH 2/3] Bump version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ec87d864eb..45540bce1a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "uwazi", - "version": "1.187.8", + "version": "1.187.9", "description": "Uwazi is a free, open-source solution for organising, analysing and publishing your documents.", "keywords": [ "react" From 5e32e6ef4643b225d38c1850ca7b00f76b57058f Mon Sep 17 00:00:00 2001 From: Daneryl Date: Fri, 11 Oct 2024 10:33:57 +0200 Subject: [PATCH 3/3] Merge back from production and Bump rc version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d96848a700..0087bd7727 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "uwazi", - "version": "1.188.0-rc9", + "version": "1.188.0-rc10", "description": "Uwazi is a free, open-source solution for organising, analysing and publishing your documents.", "keywords": [ "react"