MCPcopy Create free account
hub / github.com/adcontextprotocol/adcp / getSeatUsage

Function getSeatUsage

server/src/db/organization-db.ts:398–415  ·  view source on GitHub ↗
(orgId: string)

Source from the content-addressed store, hash-verified

396 * - they are an active member of a working group
397 */
398export async function getSeatUsage(orgId: string): Promise<{ contributor: number; community_only: number }> {
399 const pool = getPool();
400 const result = await pool.query<{ total: string; contributor: string }>(
401 `SELECT
402 COUNT(*) as total,
403 COUNT(*) FILTER (WHERE
404 om.seat_type = 'contributor'
405 OR EXISTS (SELECT 1 FROM slack_user_mappings sm WHERE sm.workos_user_id = om.workos_user_id AND sm.mapping_status = 'mapped')
406 OR EXISTS (SELECT 1 FROM working_group_memberships wgm WHERE wgm.workos_user_id = om.workos_user_id AND wgm.status = 'active')
407 ) as contributor
408 FROM organization_memberships om
409 WHERE om.workos_organization_id = $1`,
410 [orgId]
411 );
412 const total = parseInt(result.rows[0]?.total ?? '0', 10);
413 const contributor = parseInt(result.rows[0]?.contributor ?? '0', 10);
414 return { contributor, community_only: total - contributor };
415}
416
417/**
418 * Check whether a new seat of the given type can be added to an organization.

Callers 4

setupRoutesMethod · 0.85

Calls 1

getPoolFunction · 0.85

Tested by

no test coverage detected