• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

kobotoolbox / kpi / 23748212298
82%
master: 76%

Build:
Build:
LAST BUILD BRANCH: main
DEFAULT BRANCH: master
Ran 30 Mar 2026 01:53PM UTC
Jobs 10
Files 909
Run time 2min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

30 Mar 2026 01:49PM UTC coverage: 82.2% (+9.7%) from 72.523%
23748212298

push

github

web-flow
feat(api): add new endpoints for asset counts DEV-1817 (#6853)

### đŸ“Ŗ Summary
Add new endpoints for determining the count of draft, deployed, and
archived assets for a user, an organization, and a project view.


### 📖 Description
Adds three new endpoints:
`/api/v2/assets/counts`
`api/v2/organizations/{org_id}/assets/counts`
`api/v2/project-views/{pv_id}/assets/counts`
each returning the number of draft, deployed, and archived assets in the
relevant scope.


### 💭 Notes
This PR does mean we end up using `counts` as part of the url path for
both submission counts (in `/api/v2/assets/{asset_uid}/counts`) and
asset counts (in the new ` /api/v2/assets/counts`), but hopefully the
documentation makes it clear enough. The real issue is that the
submission counts should have been nested under the `data` for clarity,
but it's too late to change it without having to make a whole new API
version.

The aggregate query in the serializer turns out to be much faster than
running three smaller queries (as tested locally with ~6000 assets) and
doesn't actually cause any problems in the case of the anonymous user
even if it is wasted code/query.

SILLY PROBLEM: with lots of assets, this endpoint will crash if
--print-sql is turned on, or something else that is logging the sql
queries (eg the debug toolbar). This is because of the change in
`sqlparse` that raises errors if there are too many tokens. This is very
annoying, but solving it in a thread-safe way is worse, so we are
leaving it in.


### 👀 Preview steps

1. â„šī¸ have an account that is the owner of an MMO with at least one
other admin
2. Using the shell, create 300 assets for the org owner (no deployments)
3. Navigate to `/api/v2/assets/counts`
4. đŸŸĸ You should see `'draft_count': '300', 'deployed_count': 0,
'archived_count': 0`
5. Deploy one of the assets
6. Reload the endpoint
7. đŸŸĸ You should see `'draft_count': '299', 'deployed_count': 1,
'archived_count': 0`
8. Deploy and then archive another asset
9. Reload ... (continued)

7782 of 11983 branches covered (64.94%)

30 of 57 new or added lines in 6 files covered. (52.63%)

6 existing lines in 3 files now uncovered.

29625 of 36040 relevant lines covered (82.2%)

5.8 hits per line

Uncovered Changes

Lines Coverage ∆ File
15
69.54
-1.12% kpi/serializers/v2/asset.py
6
49.55
-1.91% kobo/apps/project_views/views.py
3
58.6
-1.67% kobo/apps/organizations/views.py
3
69.34
-0.41% kpi/views/v2/asset.py

Coverage Regressions

Lines Coverage ∆ File
3
58.6
-1.67% kobo/apps/organizations/views.py
2
44.65
-0.38% kobo/apps/openrosa/libs/utils/logger_tools.py
1
49.55
-1.91% kobo/apps/project_views/views.py
Jobs
ID Job ID Ran Files Coverage
1 23748212298.1 30 Mar 2026 01:53PM UTC 905
52.84
2 23748212298.2 30 Mar 2026 01:54PM UTC 905
54.36
3 23748212298.3 30 Mar 2026 01:55PM UTC 907
54.06
4 23748212298.4 30 Mar 2026 01:55PM UTC 907
55.61
5 23748212298.5 30 Mar 2026 01:55PM UTC 905
53.07
6 23748212298.6 30 Mar 2026 01:56PM UTC 905
60.48
7 23748212298.7 30 Mar 2026 01:57PM UTC 907
66.02
8 23748212298.8 30 Mar 2026 01:58PM UTC 907
54.41
9 23748212298.9 30 Mar 2026 01:58PM UTC 907
61.61
10 23748212298.10 30 Mar 2026 02:00PM UTC 909
68.26
Source Files on build 23748212298
  • Tree
  • List 909
  • Changed 176
  • Source Changed 0
  • Coverage Changed 176
Coverage ∆ File Lines Relevant Covered Missed Hits/Line Branch Hits Branch Misses
  • Back to Repo
  • 2617cf7b on github
  • Prev Build on main (#23690858763)
  • Next Build on main (#23748658159)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc