sub:assertion {
sub:get-weekly-active-user-count dct:description "Returns the number of active users per (approximate) week." ;
dct:license <
http://www.apache.org/licenses/LICENSE-2.0> ;
a <
https://w3id.org/kpxl/grlc/grlc-query> ;
rdfs:label "Get weekly active user count" ;
<
https://w3id.org/kpxl/grlc/endpoint> <
https://w3id.org/np/l/nanopub-query-1.1/repo/full> ;
<
https://w3id.org/kpxl/grlc/sparql> """prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
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#>
prefix dct: <http://purl.org/dc/terms/>
prefix prov: <http://www.w3.org/ns/prov#>
prefix foaf: <http://xmlns.com/foaf/0.1/>
select ?approxweek (substr(str(min(?date)), 0, 11) as ?firstday) (count(distinct ?userid) as ?usercount) where {
{ graph npa:graph {
?np npa:hasValidSignatureForPublicKey ?pubkey .
?np dct:creator ?userid .
?np dct:created ?date .
} }
union
{
graph npa:graph {
?np npa:hasValidSignatureForPublicKey ?pubkey .
?np np:hasAssertion ?assertion .
?np np:hasProvenance ?prov .
?np dct:created ?date .
}
graph ?prov {
?assertion prov:wasAttributedTo ?userid .
}
}
filter not exists {
graph npa:graph { ?np npa:hasSubIri ?userid . }
}
bind(floor((year(?date)*365 + month(?date)*365/12 + day(?date)) / 7) as ?approxweek)
}
group by ?approxweek
order by desc(?approxweek)""" .
}