Skip to content

Commit

Permalink
PROBE-218: Add date filter
Browse files Browse the repository at this point in the history
  • Loading branch information
MPParsley committed Jul 2, 2024
1 parent 8eea4aa commit 30e0a02
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
9 changes: 9 additions & 0 deletions webcomponents/besluiten-lijst/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@ <h1>Besluiten lijst</h1>
>
<span slot="title">Alle besluiten gemeenteraad en burgemeester voor het thema "Wegenregister" (probe)</span>
</besluiten-lijst>
<besluiten-lijst
sparql-endpoint="https://probe.stad.gent/sparql"
aantal="5"
pager="true"
start="2024-01-01"
eind="2024-01-31"
>
<span slot="title">Alle besluiten tussen 1 januari 2024 en 31 januari 2024 (probe)</span>
</besluiten-lijst>
<besluiten-lijst
sparql-endpoint="https://probe.stad.gent/sparql"
aantal="1"
Expand Down
12 changes: 12 additions & 0 deletions webcomponents/besluiten-lijst/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,18 @@ class BesluitenLijst extends HTMLElement {
filterparams += "VALUES ?bestuursorgaanURI { " + bestuursorganenArray.map(bestuursorgaan => `<${bestuursorgaan.trim()}>`).join(" ") + " }"
}

// Date filter.
const startdate = this.getAttribute('start');
const enddate = this.getAttribute('eind');
if (startdate && enddate) {
filterparams += `FILTER(?zitting_datum >= "${startdate}"^^xsd:date && ?zitting_datum <= "${enddate}"^^xsd:date)`;
console.log(filterparams)
} else if (startdate) {
filterparams += `FILTER(?zitting_datum >= "${startdate}"^^xsd:date)`;
} else if (enddate) {
filterparams += `FILTER(?zitting_datum <= "${enddate}"^^xsd:date)`;
}

let queryBestuursorgaan = `
prov:wasGeneratedBy/dct:subject ?agendapunt .
Expand Down
11 changes: 11 additions & 0 deletions webcomponents/reglementen-lijst/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,17 @@ class ReglementenLijst extends HTMLElement {
filterparams += "VALUES ?bestuursorgaanURI { " + bestuursorganenArray.map(bestuursorgaan => `<${bestuursorgaan.trim()}>`).join(" ") + " }"
}

// Date filter.
const startdate = this.getAttribute('start');
const enddate = this.getAttribute('eind');
if (startdate && enddate) {
filterparams += `FILTER(?zitting_datum >= "${startdate}"^^xsd:date && ?zitting_datum <= "${enddate}"^^xsd:date)`;
} else if (startdate) {
filterparams += `FILTER(?zitting_datum >= "${startdate}"^^xsd:date)`;
} else if (enddate) {
filterparams += `FILTER(?zitting_datum <= "${enddate}"^^xsd:date)`;
}

let queryBestuursorgaan = `
prov:wasGeneratedBy/dct:subject ?agendapunt .
Expand Down

0 comments on commit 30e0a02

Please sign in to comment.