@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix dct: <http://purl.org/dc/terms/> .

<https://w3id.org/np/RAwsg9J4wGkznq6vUH6MeWsRgYlQUo1DIX-MSsT3uPVJc/get-reviews-by-reviewer>
  a <https://w3id.org/kpxl/grlc/grlc-query>;
  dct:description "This query returns the items a given user has reviewed.";
  dct:license <http://www.apache.org/licenses/LICENSE-2.0>;
  rdfs:label "Get reviews by reviewer";
  <https://w3id.org/kpxl/grlc/endpoint> <https://w3id.org/np/l/nanopub-query-1.1/repo/full>;
  <https://w3id.org/kpxl/grlc/sparql> """prefix schema: <http://schema.org/>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix dct: <http://purl.org/dc/terms/>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>

select distinct ?item ?item_label ?date ?comment ?np (\"^\" as ?np_label) where {
  {
    graph npa:graph {
      ?np npa:hasValidSignatureForPublicKeyHash ?pubkey .
      filter not exists { ?npx npx:invalidates ?np ; npa:hasValidSignatureForPublicKeyHash ?pubkey . }
      ?np np:hasAssertion ?a .
      ?np dct:created ?created .
    }
    graph ?a {
      ?ra a schema:ReviewAction ;
        schema:agent ?_reviewer_iri ;
        schema:object ?item .
      optional { ?item rdfs:label ?item_label }
      optional { ?ra schema:endTime ?d }
      optional { ?ra rdfs:comment ?comment }
    }
    bind(coalesce(?d, substr(str(?created), 1, 10)) as ?date)
  }
} order by desc(?date)""" .
