Skip to content

Commit

Permalink
feat(ldes-client): update logic handling tombstones
Browse files Browse the repository at this point in the history
  • Loading branch information
elpoelma committed Dec 2, 2024
1 parent d55fc4f commit 236ece6
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/late-donkeys-travel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"app-gelinkt-notuleren": minor
---

Add migration which drops all data related to tombstones from our database
5 changes: 5 additions & 0 deletions .changeset/tasty-cycles-accept.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"app-gelinkt-notuleren": minor
---

Adjust ldes-client `processPage` logic to remove incoming tombstones entirely
30 changes: 26 additions & 4 deletions config/ldes-client/processPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,18 @@ async function replaceExistingData() {
?versionedMember ${sparqlEscapeUri(VERSION_PREDICATE)} ?s .
{
?versionedMember (a | as:formerType) ?type.
?versionedMember a ?type.
VALUES ?type { mandaat:Mandataris mandaat:Fractie org:Membership }
?versionedMember ?pNew ?oNew.
BIND(<http://mu.semte.ch/graphs/lmb-data-public> as ?target_graph)
}
UNION
{
?versionedMember (a | as:formerType) ?type.
?versionedMember a ?type.
VALUES ?type { person:Person }
?versionedMember ?pNew ?oNew.
VALUES ?pNew {
rdf:type
as:formerType
dct:modified
mu:uuid
foaf:familyName
Expand All @@ -62,7 +61,7 @@ async function replaceExistingData() {
}
UNION
{
?versionedMember (a | as:formerType) ?type.
?versionedMember a ?type.
VALUES ?type { person:Person persoon:Geboorte }
?versionedMember ?pNew ?oNew.
FILTER (?pNew NOT IN ( adms:identifier ))
Expand All @@ -77,6 +76,29 @@ async function replaceExistingData() {
}
}
};
DELETE {
GRAPH ?g {
?member ?pOut ?oOut.
?sIn ?pIn ?member.
}
}
WHERE {
GRAPH ${sparqlEscapeUri(BATCH_GRAPH)} {
?stream <https://w3id.org/tree#member> ?versionedMember .
?versionedMember ${sparqlEscapeUri(VERSION_PREDICATE)} ?member .
?versionedMember a as:Tombstone.
}
GRAPH ?g {
{
?member ?pOut ?oOut.
}
UNION
{
?sIn ?pIn ?member.
}
}
FILTER(?g != ${sparqlEscapeUri(BATCH_GRAPH)})
};
DELETE {
GRAPH <http://mu.semte.ch/graphs/lmb-data-public> {
?administrativeUnit ext:lastLMBUpdate ?oldTimestamp.
Expand Down
21 changes: 21 additions & 0 deletions config/migrations/20241129121508-clean-up-tombstones.sparql
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
PREFIX as: <http://www.w3.org/ns/activitystreams#>

DELETE {
GRAPH ?g {
?tombstone a as:Tombstone.
?tombstone ?p_out ?o_out.
?s_in ?p_in ?tombstone.
}
}
WHERE {
GRAPH ?g {
?tombstone a as:Tombstone.
{
?tombstone ?p_out ?o_out.
}
UNION
{
?s_in ?p_in ?tombstone.
}
}
}

0 comments on commit 236ece6

Please sign in to comment.