Summary
When attempting to delete an organization, the confirmation modal displays an incorrect number of links that need to be handled (deleted or migrated). The modal shows the monthly link creation count at the billing account level instead of the actual number of links in the specific organization being deleted.
Steps to Reproduce
- Set up a Business account with multiple organizations
- Import/create links in the main organization (e.g., 11 links)
- Create additional organizations with no links
- Attempt to delete one of the empty organizations
- Observe that the modal warns about links existing in the organization (e.g., shows 1 link instead of 0)
- If migration is selected and the target org is also empty, no links are actually moved (because the source org was empty)
Expected Behavior
The modal should show the actual number of links in the organization being deleted (0 for an empty org), not the monthly link creation count across the entire billing account.
Actual Behavior
The modal shows links_created_this_month from the /api/usage endpoint, which counts links at the billing account level (all links created this month across all organizations), not the per-organization link count.
Root Cause
In frontend/src/routes/dashboard/org/+page.svelte (lines 366-368):
// Get link count from usage API
const usage = await orgsApi.getUsage();
linkCount = usage.usage?.links_created_this_month || 0;
The /api/usage endpoint returns links_created_this_month at the billing account level (see src/api/analytics/usage.rs lines 57-59), which is the count of all links created this month across all organizations in the billing account.
Impact
- Users may incorrectly believe an empty organization contains links
- This could lead to unnecessary migration operations or incorrect deletion decisions
- Not currently affecting production users as Business plan is not yet public
Suggested Fix
Add the link count to the /api/orgs/{id} API response, then update the frontend to use this per-organization link count instead of the billing account-level monthly count from /api/usage.
Alternative: Call /api/links filtered by org_id to get the actual count for the specific organization being deleted.
Summary
When attempting to delete an organization, the confirmation modal displays an incorrect number of links that need to be handled (deleted or migrated). The modal shows the monthly link creation count at the billing account level instead of the actual number of links in the specific organization being deleted.
Steps to Reproduce
Expected Behavior
The modal should show the actual number of links in the organization being deleted (0 for an empty org), not the monthly link creation count across the entire billing account.
Actual Behavior
The modal shows
links_created_this_monthfrom the/api/usageendpoint, which counts links at the billing account level (all links created this month across all organizations), not the per-organization link count.Root Cause
In
frontend/src/routes/dashboard/org/+page.svelte(lines 366-368):The
/api/usageendpoint returnslinks_created_this_monthat the billing account level (seesrc/api/analytics/usage.rslines 57-59), which is the count of all links created this month across all organizations in the billing account.Impact
Suggested Fix
Add the link count to the
/api/orgs/{id}API response, then update the frontend to use this per-organization link count instead of the billing account-level monthly count from/api/usage.Alternative: Call
/api/linksfiltered byorg_idto get the actual count for the specific organization being deleted.