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

kobotoolbox / kpi / 23748212298 / 6
82%
master: 76%

Build:
Build:
LAST BUILD BRANCH: beccagraber/dev-2030-500-from-migration
DEFAULT BRANCH: master
Ran 30 Mar 2026 01:56PM UTC
Files 905
Run time 23s
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: 60.481% (+0.04%) from 60.446%
23748212298.6

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)

4671 of 11894 branches covered (39.27%)

21743 of 35950 relevant lines covered (60.48%)

0.6 hits per line

Source Files on job 23748212298.6
  • Tree
  • List 905
  • Changed 6
  • Source Changed 0
  • Coverage Changed 6
Coverage ∆ File Lines Relevant Covered Missed Hits/Line Branch Hits Branch Misses
  • Back to Build 23748212298
  • 2617cf7b on github
  • Prev Job for on main (#23690858763.5)
  • Next Job for on main (#23748658159.2)
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