OP-3810: cleanup migration to keep currently active orgaan + remove mandates from removed organen

This commit is contained in:
Damon
2026-07-07 16:27:24 +02:00
parent 1a4453365f
commit f545b55075

View File

@@ -9,6 +9,8 @@ DELETE {
GRAPH <http://mu.semte.ch/graphs/worship-service> {
?otherOrgaanInTime ?p ?o .
?s ?p2 ?otherOrgaanInTime .
?mandate ?mp ?mo .
?ms ?mp2 ?mandate .
}
}
WHERE {
@@ -18,22 +20,30 @@ WHERE {
?bestuursorgaan besluit:bestuurt ?worshipService .
?otherOrgaanInTime generiek:isTijdspecialisatieVan ?bestuursorgaan .
{
SELECT ?bestuursorgaan (SAMPLE(?orgaanInTime) AS ?keptOrgaanInTime) {
SELECT ?bestuursorgaan (MAX(?start) AS ?keptStart) {
GRAPH <http://mu.semte.ch/graphs/worship-service> {
?orgaanInTime generiek:isTijdspecialisatieVan ?bestuursorgaan .
?orgaanInTime generiek:isTijdspecialisatieVan ?bestuursorgaan ;
mandaat:bindingStart ?start .
FILTER(?start <= NOW())
}
}
GROUP BY ?bestuursorgaan
}
?keptOrgaanInTime generiek:isTijdspecialisatieVan ?bestuursorgaan ;
mandaat:bindingStart ?keptStart .
?otherOrgaanInTime generiek:isTijdspecialisatieVan ?bestuursorgaan .
FILTER(?otherOrgaanInTime != ?keptOrgaanInTime)
{ ?otherOrgaanInTime ?p ?o . }
UNION
{ ?s ?p2 ?otherOrgaanInTime . }
UNION
{ ?otherOrgaanInTime org:hasPost ?mandate . ?mandate ?mp ?mo . }
UNION
{ ?otherOrgaanInTime org:hasPost ?mandate . ?ms ?mp2 ?mandate . }
}
};