Wiki source code of Total Installs for the last 365 days
Last modified by Vincent Massol on 2019/01/11
Show last authors
author | version | line-number | content |
---|---|---|---|
1 | {{include reference="ActiveInstalls.QueryVariables"/}} | ||
2 | {{velocity}} | ||
3 | ##========================= | ||
4 | ## New way for XWiki 6.1M1+ | ||
5 | ##========================= | ||
6 | #set ($query = " | ||
7 | { | ||
8 | ""query"": { | ||
9 | ""query_string"": { | ||
10 | ""lowercase_expanded_terms"": false, | ||
11 | ""query"": ""_timestamp:[now-365d TO *] $snapshotQueryFragment AND distributionId:${distributionId.replace(':', '\\:')}"" | ||
12 | } | ||
13 | }, | ||
14 | ""aggs"": { | ||
15 | ""instanceId_count"": { | ||
16 | ""cardinality"": { | ||
17 | ""field"": ""instanceId"" | ||
18 | } | ||
19 | } | ||
20 | } | ||
21 | } | ||
22 | ") | ||
23 | #set ($result = $services.activeinstalls.searchInstalls("install2", $query, {"search_type": "count"})) | ||
24 | ## If there's an error and the "xpage=plain" URL parameter is not passed (ie it's not called by the Counter widget) then display the error if any. Otherwise display the invalid numeric result. | ||
25 | #if (!$result) | ||
26 | #set ($errorText = $!services.activeinstalls.lastError) | ||
27 | #if ("$!request.xpage" != 'plain') | ||
28 | {{error}}{{{$errorText}}}{{/error}} | ||
29 | #else | ||
30 | 0 | ||
31 | #end | ||
32 | #else | ||
33 | $result.getAsJsonObject("aggregations").getAsJsonObject("instanceId_count").getAsJsonPrimitive("value").getAsLong() | ||
34 | #end | ||
35 | {{/velocity}} |