-
Notifications
You must be signed in to change notification settings - Fork 108
add dependencies / dependents count to /project #158
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
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.
Pull Request Overview
This PR adds dependency and dependent counts to the /project/:id endpoint response. The change enhances the project endpoint by including two new fields: dependenciesCount (packages this project depends on) and dependentsCount (packages that depend on this project).
Key changes:
- Added SQL subqueries to count dependencies and dependents using existing database indexes
- Extended the project endpoint response with two new count fields
| ) AS "packageManagers" | ||
| ) AS "packageManagers", | ||
| ( | ||
| SELECT COUNT(*)::bigint |
Copilot
AI
Aug 11, 2025
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.
The COUNT(*) subquery for dependenciesCount could be expensive for projects with many dependencies. Consider adding LIMIT clause or monitoring query performance, especially if this endpoint is frequently accessed.
| FROM legacy_dependencies ld | ||
| JOIN canon_packages cp_in ON cp_in.package_id = ld.dependency_id | ||
| WHERE cp_in.canon_id = c.id |
Copilot
AI
Aug 11, 2025
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.
The COUNT(*) subquery for dependentsCount could be expensive for popular projects with many dependents. Consider adding LIMIT clause or monitoring query performance, especially if this endpoint is frequently accessed.
| FROM legacy_dependencies ld | |
| JOIN canon_packages cp_in ON cp_in.package_id = ld.dependency_id | |
| WHERE cp_in.canon_id = c.id | |
| FROM ( | |
| SELECT 1 | |
| FROM legacy_dependencies ld | |
| JOIN canon_packages cp_in ON cp_in.package_id = ld.dependency_id | |
| WHERE cp_in.canon_id = c.id | |
| LIMIT $2 | |
| ) sub |
|
looks good! thanks, @sanchitram1 . |
{ "dependenciesCount": 29, "dependentsCount": 1, "homepage": "github.com/andy-shea/redux-formalize", "name": "redux-formalize", "packageManagers": [ "npm" ], "projectId": "5cfc3fa4-f04a-417a-a0be-b09a1380b033", "source": "github.com/andy-shea/redux-formalize", "teaRank": "0", "teaRankCalculatedAt": null }quick bc we already have all the necessary indexes, no need for materialized views or anything yet. i've also only added the data point to the
/project/:idendpoint