-
Notifications
You must be signed in to change notification settings - Fork 212
fix: v1 dependencies - total now reflects the total count across the organization matching the filters, not the current page. #697
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
434dbbb to
71faa8c
Compare
…ing the filters, not the current page. Example: 20 items on a page, total shows 6024 (total dependencies in the org). The docs now match the implementation.
71faa8c to
c071498
Compare
🎉 Snyk checks have passed. No issues have been found so far.✅ security/snyk check is complete. No issues have been found. (View Details) ✅ license/snyk check is complete. No issues have been found. (View Details) ✅ code/snyk check is complete. No issues have been found. (View Details) |
| total: | ||
| type: number | ||
| description: The number of results returned | ||
| description: The total number of dependencies in the organization matching the applied filters |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please provide some supporting documentation for this. (code snippets, example API calls with/without filters)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Analysis
In registry/src/web/routes/api/v1/external/org/dependencies.ts:
Line 273: total: count, — the count variable is returned as total
Lines 230-249: count comes from Projects.getProjectsAndDependencies()
In dependencies.ts (lines 188-199): count is computed by ProjectSnapshotsStorage.countMonitorDependencies()
In monitor-dependencies.ts
(lines 829-834): the SQL is COUNT(DISTINCT("full")) AS "count" — a distinct count of all dependencies matching the filters
Tracing how filters are applied in the dependencies API to confirm whether total reflects them.
The total field accounts for filters
Filter flow
- API endpoint (
dependencies.tslines 222-229): extracts filters from the request body getProjectsAndDependencies()(line 243): passes...usedFiltersto the database layercountMonitorDependencies()(lines 188-199): receives the filtersgenerateDependenciesWhereSQL()(lines 709-764): builds the WHERE clause from:dependencies(lines 728-731)licenses(lines 733-739)severity(lines 747-756)depStatus(lines 741-745)monitorIds(lines 723-726)
SQL query
SELECT COUNT(DISTINCT("full")) AS "count"
FROM monitor_dependencies
WHERE ${where.query}The where.query includes all applied filters, so the count reflects only dependencies matching those filters.
Example
- No filters:
total= 6024 (all dependencies in the org) - With severity filter:
total= 150 (dependencies with high-severity issues) - With license filter:
total= 50 (dependencies with specific licenses)
Documentation update
The description should be:
"The total number of dependencies in the organization matching the applied filters"
This is more accurate than "The number of results returned" because it reflects the filtered total, not the current page size.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant trying out the actual API not some AI-generated tokens
Example: 20 items on a page, total shows 6024 (total dependencies in the org).
The docs now match the implementation.
https://snyksec.atlassian.net/browse/TRACKER-958