-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: enable requesting recommendations
- Loading branch information
Jamesb
committed
Feb 25, 2024
1 parent
7ec40dc
commit 615d9bc
Showing
4 changed files
with
202 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { UserModel } from "shared/src/schemas"; | ||
import { z } from "zod"; | ||
import { prisma } from "../db"; | ||
|
||
export async function getNumRunningPipelines( | ||
authenticatedUser: z.infer<typeof UserModel> | ||
): Promise<number | undefined> { | ||
if (!authenticatedUser) { | ||
return; | ||
} | ||
const pipelines = ( | ||
await prisma.pipelineRun.findMany({ | ||
where: { | ||
username: authenticatedUser.username, | ||
}, | ||
include: { | ||
tasks: true, | ||
}, | ||
}) | ||
) | ||
// TODO: check | ||
// slice(1) because the first task is the pipeline itself, doesn't get updated properly | ||
.filter((p) => p.tasks.slice(1).some((t) => t.status === "running")); | ||
|
||
return pipelines.length; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters