Skip to content

Conversation

@sanchitram1
Copy link
Contributor

@sanchitram1 sanchitram1 commented Aug 11, 2025

{
"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/:id endpoint

@sanchitram1 sanchitram1 changed the title add dependencies / dependents count to /projects add dependencies / dependents count to /project Aug 11, 2025
@jhheider jhheider requested a review from Copilot August 11, 2025 13:57
Copy link
Contributor

Copilot AI left a 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
Copy link

Copilot AI Aug 11, 2025

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.

Copilot uses AI. Check for mistakes.
Comment on lines +230 to +232
FROM legacy_dependencies ld
JOIN canon_packages cp_in ON cp_in.package_id = ld.dependency_id
WHERE cp_in.canon_id = c.id
Copy link

Copilot AI Aug 11, 2025

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.

Suggested change
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

Copilot uses AI. Check for mistakes.
@jhheider
Copy link
Member

looks good! thanks, @sanchitram1 .

@jhheider jhheider merged commit cde374f into teaxyz:main Aug 11, 2025
4 checks passed
@sanchitram1 sanchitram1 deleted the api/dependencies-count branch August 11, 2025 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants