diff --git a/.gitignore b/.gitignore index d6b6a17..f5c1878 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ docker-compose.override.yml *.iml /data/elasticsearch/** +/data/ldes-feed/* /tmp .DS_STORE .env diff --git a/config/ldes-delta-pusher/dispatch.ts b/config/ldes-delta-pusher/dispatch.ts index 2c1bf3c..ba852e3 100644 --- a/config/ldes-delta-pusher/dispatch.ts +++ b/config/ldes-delta-pusher/dispatch.ts @@ -1,13 +1,29 @@ import { moveTriples } from "../support"; import { Changeset } from "../types"; +import { query, sparqlEscapeUri } from 'mu'; export default async function dispatch(changesets: Changeset[]) { for (const changeset of changesets) { - await moveTriples([ - { - inserts: changeset.inserts, - deletes: changeset.deletes, - }, - ]); + const subjects = new Set(changeset.inserts.map((insert) => insert.subject.value)); + for (const subject of subjects) { + const { results: { bindings } } = await query(` + PREFIX org: + CONSTRUCT { + ${sparqlEscapeUri(subject)} a org:Organization; + ?p ?o. + } + WHERE { + ${sparqlEscapeUri(subject)} a org:Organization; + ?p ?o. + } + `); + if(bindings.length){ + await moveTriples([ + { + inserts: bindings.map(({ s, p, o}) => { return { subject: s, predicate: p, object: o} }), + } + ]) + } + } } } \ No newline at end of file diff --git a/data/ldes-feed/organizations/1.ttl b/data/ldes-feed/organizations/1.ttl deleted file mode 100644 index c942bf9..0000000 --- a/data/ldes-feed/organizations/1.ttl +++ /dev/null @@ -1,111 +0,0 @@ - - . - - . - - <./1> . - -<./1> . - - . - - . - - . - - "63EB64180A219366CF7BB44B" . - - . - - "2023-02-14T10:36:08.610Z"^^ . - - . - - "63eb642dabf18a000e000001" . - - . - - "2023-02-14T10:36:29.642Z"^^ . - - . - - "2023-02-14T10:36:29+00:00" . - - . - - "ABBOrganisatiePortaalGebruiker-editeerder" . - - . - - "63eb64b3abf18a000e000002" . - - . - - "2023-02-14T10:38:43.728Z"^^ . - - . - - "2023-02-14T10:38:43+00:00" . - - . - - "ABBOrganisatiePortaalGebruiker-beheerder" . - - . - - . - - "ee75bd30-ac53-11ed-bc10-e3552d6f40d6" . - - . - - "2023-02-14T10:40:00.146Z"^^ . - - "2023-02-14T10:40:00.131Z" . - - . - - "2023-02-14T10:40:00.131Z" . - - . - - . - - . - - . - - "ee771cc0-ac53-11ed-bc10-e3552d6f40d6" . - - . - - "2023-02-14T10:40:00.154Z"^^ . - - "2023-02-14T10:40:00.140Z" . - - . - - "2023-02-14T10:40:00.140Z" . - - . - - . - - "0" . - - . - - . - - "2023-02-14T10:40:01.204Z"^^ . - - . - - . - - . - - . - - "2023-02-14T10:40:01.224Z"^^ . - diff --git a/docker-compose.yml b/docker-compose.yml index b5ebcfc..e259310 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -564,11 +564,13 @@ services: ldes-delta-pusher: image: redpencil/ldes-delta-pusher:latest environment: - LDES_ENDPOINT: 'http://fragmentation-producer/organizations' + LDES_ENDPOINT: 'http://ldes-backend/organizations' volumes: - ./config/ldes-delta-pusher/:/config/ + links: + - db:database - fragmentation-producer: + ldes-backend: image: redpencil/fragmentation-producer:0.1.3 environment: FOLDER_DEPTH: 1