more Free/Pro plan limitations

This commit is contained in:
2026-01-28 23:36:03 +00:00
parent 7f3cb7c890
commit 14520618d1
14 changed files with 296 additions and 55 deletions

View File

@@ -14,4 +14,5 @@ export const FREE_TIER_LIMITS = {
projectsPerOrganisation: 1,
issuesPerOrganisation: 100,
membersPerOrganisation: 5,
sprintsPerProject: 5,
} as const;

View File

@@ -152,3 +152,13 @@ export async function getUserOrganisationCount(userId: number): Promise<number>
.where(eq(OrganisationMember.userId, userId));
return result?.count ?? 0;
}
export async function getOrganisationOwner(organisationId: number) {
const [owner] = await db
.select({ userId: OrganisationMember.userId })
.from(OrganisationMember)
.where(
and(eq(OrganisationMember.organisationId, organisationId), eq(OrganisationMember.role, "owner")),
);
return owner;
}

View File

@@ -1,5 +1,5 @@
import { Issue, Sprint } from "@sprint/shared";
import { and, desc, eq, gte, lte, ne } from "drizzle-orm";
import { and, desc, eq, gte, lte, ne, sql } from "drizzle-orm";
import { db } from "../client";
export async function createSprint(
@@ -72,3 +72,11 @@ export async function deleteSprint(sprintId: number) {
await db.update(Issue).set({ sprintId: null }).where(eq(Issue.sprintId, sprintId));
await db.delete(Sprint).where(eq(Sprint.id, sprintId));
}
export async function getProjectSprintCount(projectId: number) {
const result = await db
.select({ count: sql<number>`count(*)::int` })
.from(Sprint)
.where(eq(Sprint.projectId, projectId));
return result[0]?.count ?? 0;
}