This issue has been created
There are 2 updates.
 
 
XWiki Platform / cid:jira-generated-image-avatar-24441a13-ded3-4fe5-a60a-fda03f691073 XWIKI-24710 Open

Add script APIs to count distinct active installs globally and per extension

 
View issue   ยท   Add comment
 

Issue created

 
cid:jira-generated-image-avatar-05c3d405-95e7-401c-b8e2-a29656f9e569 Vincent Massol created this issue on 15/Aug/26 11:20
 
Summary: Add script APIs to count distinct active installs globally and per extension
Issue Type: cid:jira-generated-image-avatar-24441a13-ded3-4fe5-a60a-fda03f691073 Improvement
Assignee: Unassigned
Components: Active Installs
Created: 15/Aug/26 11:20
Priority: cid:jira-generated-image-static-major-1201e70e-1a29-4182-8158-3267d70f8d35 Major
Reporter: Vincent Massol
Description:

Problem

The Active Installs 2 script service (services.activeinstalls2) exposes only two methods, and neither can produce the number Active Installs exists to provide: how many distinct XWiki instances are running.

  • countInstalls(String) returns a document count, i.e. a number of pings, not a number of instances. An instance pings once a day but also on every restart, so the value is inflated. Measured on extensions.xwiki.org over the last day, the extension org.xwiki.platform:xwiki-platform-dashboard-ui matched 8486 pings but only 7054 distinct instances, a 20% overestimate.
  • searchInstalls(String) returns the raw hits, capped by Elasticsearch's default page size of 10, and the JSON it accepts is only the query part of the request body, so no aggs can be attached to it.

Counting distinct instances requires a cardinality aggregation on distribution.instanceId, and there is no way to run one through the script service. The Active Installs 1 script service did support this: it took the full Elasticsearch request body, aggregations included, and returned the parsed JSON response.

Consequence

The scheduler job on extensions.xwiki.org that refreshes the "installed count" shown on every extension page still queries the Active Installs 1 Elasticsearch instance only, because that is the only one it can get a distinct-instance count out of. It reports around 1200 instances a day where the real total is above 9000, so almost every extension page understates its install count by close to an order of magnitude.

Working around this today means bypassing the script service entirely and talking to the Elasticsearch REST endpoint from Groovy, which puts the query, the index layout and the HTTP handling in a wiki page.

Proposal

Add two methods to ActiveInstallsScriptService (and to DataManager behind it):

  • countDistinctInstalls(String jsonQuery) returning the number of distinct instances matching the query.
  • countDistinctInstallsByExtension(String jsonQuery) returning, in a single Elasticsearch request, the number of distinct instances per extension id.

The second one also hides a detail that no script author is likely to get right: extensions is mapped as a nested type, so reaching the instance id from an extension bucket needs a reverse_nested aggregation.

 
 

2 updates

 
cid:jira-generated-image-avatar-05c3d405-95e7-401c-b8e2-a29656f9e569 Changes by Vincent Massol on 15/Aug/26 11:21
 
Fix Version: 18.7.0-rc-1
Assignee: Vincent Massol