Skip to content

Commit

Permalink
#17: updated ingest function
Browse files Browse the repository at this point in the history
  • Loading branch information
darnjo committed Feb 10, 2023
1 parent 08e0638 commit 01259ab
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions api/services/data-access.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,17 @@ const ingest = async (providerUoi, uliData = []) => {

try {
const ndJson =
uliData.reduce((acc, licensee) => {
acc += JSON.stringify({ index: {} }) + "\n";
acc +=
uliData.flatMap((licensee) => {
return [
JSON.stringify({ index: {} }),
JSON.stringify({
ingestTimestamp: new Date().toISOString(),
providerUoi,
status: "unprocessed",
...licensee,
}) + "\n";
return acc;
}, "") + "\n";
})
]
}).join("\n") + "\n";

const response = await post(
`${ES_URL}/${ULI_SERVICE_INDEX}/_bulk`,
Expand Down

0 comments on commit 01259ab

Please sign in to comment.