mirror of
https://github.com/hex248/sprint.git
synced 2026-02-08 18:33:01 +00:00
Free/Pro plan limitations
This commit is contained in:
@@ -7,3 +7,11 @@ export * from "./sprints";
|
||||
export * from "./subscriptions";
|
||||
export * from "./timed-sessions";
|
||||
export * from "./users";
|
||||
|
||||
// free tier limits
|
||||
export const FREE_TIER_LIMITS = {
|
||||
organisationsPerUser: 1,
|
||||
projectsPerOrganisation: 1,
|
||||
issuesPerOrganisation: 100,
|
||||
membersPerOrganisation: 5,
|
||||
} as const;
|
||||
|
||||
@@ -259,6 +259,25 @@ export async function getIssueAssigneeCount(issueId: number): Promise<number> {
|
||||
return result?.count ?? 0;
|
||||
}
|
||||
|
||||
export async function getOrganisationIssueCount(organisationId: number): Promise<number> {
|
||||
const { Project } = await import("@sprint/shared");
|
||||
|
||||
const projects = await db
|
||||
.select({ id: Project.id })
|
||||
.from(Project)
|
||||
.where(eq(Project.organisationId, organisationId));
|
||||
const projectIds = projects.map((p) => p.id);
|
||||
|
||||
if (projectIds.length === 0) return 0;
|
||||
|
||||
const [result] = await db
|
||||
.select({ count: sql<number>`COUNT(*)` })
|
||||
.from(Issue)
|
||||
.where(inArray(Issue.projectId, projectIds));
|
||||
|
||||
return result?.count ?? 0;
|
||||
}
|
||||
|
||||
export async function isIssueAssignee(issueId: number, userId: number): Promise<boolean> {
|
||||
const [assignee] = await db
|
||||
.select({ id: IssueAssignee.id })
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Organisation, OrganisationMember, User } from "@sprint/shared";
|
||||
import { and, eq } from "drizzle-orm";
|
||||
import { and, eq, sql } from "drizzle-orm";
|
||||
import { db } from "../client";
|
||||
|
||||
export async function createOrganisation(name: string, slug: string, description?: string) {
|
||||
@@ -144,3 +144,11 @@ export async function updateOrganisationMemberRole(organisationId: number, userI
|
||||
.returning();
|
||||
return member;
|
||||
}
|
||||
|
||||
export async function getUserOrganisationCount(userId: number): Promise<number> {
|
||||
const [result] = await db
|
||||
.select({ count: sql<number>`COUNT(*)` })
|
||||
.from(OrganisationMember)
|
||||
.where(eq(OrganisationMember.userId, userId));
|
||||
return result?.count ?? 0;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Issue, Organisation, Project, Sprint, User } from "@sprint/shared";
|
||||
import { eq } from "drizzle-orm";
|
||||
import { eq, sql } from "drizzle-orm";
|
||||
import { db } from "../client";
|
||||
|
||||
export async function createProject(key: string, name: string, creatorId: number, organisationId: number) {
|
||||
@@ -82,3 +82,11 @@ export async function getProjectsByOrganisationId(organisationId: number) {
|
||||
.leftJoin(Organisation, eq(Project.organisationId, Organisation.id));
|
||||
return projects;
|
||||
}
|
||||
|
||||
export async function getOrganisationProjectCount(organisationId: number): Promise<number> {
|
||||
const [result] = await db
|
||||
.select({ count: sql<number>`COUNT(*)` })
|
||||
.from(Project)
|
||||
.where(eq(Project.organisationId, organisationId));
|
||||
return result?.count ?? 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user