mirror of
https://github.com/hex248/sprint.git
synced 2026-02-09 02:33:02 +00:00
improved timer system and overlay
This commit is contained in:
@@ -97,6 +97,35 @@ export async function getIssueByID(id: number) {
|
||||
return issue;
|
||||
}
|
||||
|
||||
export async function getIssueWithUsersById(issueId: number): Promise<IssueResponse | null> {
|
||||
const Creator = aliasedTable(User, "Creator");
|
||||
|
||||
const [issueWithCreator] = await db
|
||||
.select({
|
||||
Issue: Issue,
|
||||
Creator: Creator,
|
||||
})
|
||||
.from(Issue)
|
||||
.where(eq(Issue.id, issueId))
|
||||
.innerJoin(Creator, eq(Issue.creatorId, Creator.id));
|
||||
|
||||
if (!issueWithCreator) return null;
|
||||
|
||||
const assigneesData = await db
|
||||
.select({
|
||||
User: User,
|
||||
})
|
||||
.from(IssueAssignee)
|
||||
.innerJoin(User, eq(IssueAssignee.userId, User.id))
|
||||
.where(eq(IssueAssignee.issueId, issueId));
|
||||
|
||||
return {
|
||||
Issue: issueWithCreator.Issue,
|
||||
Creator: issueWithCreator.Creator,
|
||||
Assignees: assigneesData.map((row) => row.User),
|
||||
};
|
||||
}
|
||||
|
||||
export async function getIssueByNumber(projectId: number, number: number) {
|
||||
const [issue] = await db
|
||||
.select()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { TimedSession } from "@sprint/shared";
|
||||
import { Issue, Project, TimedSession } from "@sprint/shared";
|
||||
import { and, desc, eq, isNotNull, isNull } from "drizzle-orm";
|
||||
import { db } from "../client";
|
||||
|
||||
@@ -80,6 +80,26 @@ export async function getUserTimedSessions(userId: number, limit = 50, offset =
|
||||
return timedSessions;
|
||||
}
|
||||
|
||||
export async function getActiveTimedSessionsWithIssue(userId: number) {
|
||||
const timedSessions = await db
|
||||
.select({
|
||||
id: TimedSession.id,
|
||||
userId: TimedSession.userId,
|
||||
issueId: TimedSession.issueId,
|
||||
timestamps: TimedSession.timestamps,
|
||||
endedAt: TimedSession.endedAt,
|
||||
createdAt: TimedSession.createdAt,
|
||||
issueNumber: Issue.number,
|
||||
projectKey: Project.key,
|
||||
})
|
||||
.from(TimedSession)
|
||||
.innerJoin(Issue, eq(TimedSession.issueId, Issue.id))
|
||||
.innerJoin(Project, eq(Issue.projectId, Project.id))
|
||||
.where(and(eq(TimedSession.userId, userId), isNull(TimedSession.endedAt)))
|
||||
.orderBy(desc(TimedSession.createdAt));
|
||||
return timedSessions;
|
||||
}
|
||||
|
||||
export async function getCompletedTimedSessions(userId: number, limit = 50, offset = 0) {
|
||||
const timedSessions = await db
|
||||
.select()
|
||||
|
||||
Reference in New Issue
Block a user