diff --git a/README.md b/README.md index 36f0968..68ebe0e 100644 --- a/README.md +++ b/README.md @@ -148,6 +148,22 @@ sbt "runMain rpb.ETL conf/test-export-strapi-to-lobid.flux" This writes individual `.json` files for Strapi records to `output/`. +### Compare export data + +```bash +sbt "runMain rpb.ETL conf/test-export-compare-strapi.flux PICK=all_equal('f36_','u') PATH=articles" +sbt "runMain rpb.ETL conf/test-export-compare-strapi.flux PICK=all_equal('f36_','s') PATH=independent-works" +sbt "runMain rpb.ETL conf/test-export-compare-strapi.flux PICK=all_equal('f36_','sbd') PATH=independent-works" +sbt "runMain rpb.ETL conf/test-export-compare-strapi.flux PICK=all_equal('f36t','MultiVolumeBook') PATH=independent-works" +``` + +This selects parts of the test data and write two files: + +1) for each test record, get the data from the Strapi HTTP API, convert the result to the lobid format, write to `test-lobid-output-from-strapi.json` +2) convert each record directly to lobid, write to `test-lobid-output-from-strapi.json` + +We can then compare the two files (e.g. in VSC: Select for Compare, Format Document) to see differences. Since fields that are not defined in the Strapi content types are omitted upon import, missing data here points to missing fields in the Strapi content types. + ### Validate output Prerequisites: `npm install -g ajv-cli ajv-formats` diff --git a/conf/test-export-compare-strapi.flux b/conf/test-export-compare-strapi.flux new file mode 100644 index 0000000..7827808 --- /dev/null +++ b/conf/test-export-compare-strapi.flux @@ -0,0 +1,37 @@ +// Get test data for the specified type; for each record, +// fetch the entry from Strapi, convert that to lobid, write. +FLUX_DIR + "output/test-output-strapi.json" +| open-file +| as-lines +| decode-json +| fix(" +unless " + PICK + " + reject() +end +prepend(f00_, 'http://rpb-cms-test.lobid.org/api/" + PATH + "?populate=*&filters[f00_][$eq]=') +retain(f00_) +") +| literal-to-object +| log-object("Strapi URL: ") +| open-http +| as-records +| decode-json(recordPath="data.[*].attributes") +| fix(FLUX_DIR + "rpb-titel-to-lobid.fix") +| encode-json +| write(FLUX_DIR + "output/test-lobid-output-from-strapi.json") +; + +// To compare, convert test data directly to lobid, write. +FLUX_DIR + "output/test-output-strapi.json" +| open-file +| as-lines +| decode-json +| fix(" +unless " + PICK + " + reject() +end +") +| fix(FLUX_DIR + "rpb-titel-to-lobid.fix") +| encode-json +| write(FLUX_DIR + "output/test-lobid-output-from-file.json") +;