feat(api): progressFromTasks im Projekt-Endpunkt
Der Schalter laesst sich ueber PATCH /api/projects/:id setzen. Beim Einschalten wird der abgeleitete Wert sofort berechnet, damit er nicht bis zur naechsten Aufgabenaenderung falsch steht. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -4,6 +4,7 @@ import { prisma } from "@/lib/db";
|
|||||||
import { parseRepoUrl } from "@/lib/git";
|
import { parseRepoUrl } from "@/lib/git";
|
||||||
import { projectDetailInclude, projectListInclude, uniqueSlug } from "@/lib/projects";
|
import { projectDetailInclude, projectListInclude, uniqueSlug } from "@/lib/projects";
|
||||||
import { jsonError, readJsonBody } from "@/lib/security/request";
|
import { jsonError, readJsonBody } from "@/lib/security/request";
|
||||||
|
import { refreshDerivedProgress } from "@/lib/tasks";
|
||||||
import { formatZodError, projectUpdateSchema } from "@/lib/validation";
|
import { formatZodError, projectUpdateSchema } from "@/lib/validation";
|
||||||
|
|
||||||
export const dynamic = "force-dynamic";
|
export const dynamic = "force-dynamic";
|
||||||
@@ -75,6 +76,7 @@ export async function PATCH(request: Request, { params }: Params) {
|
|||||||
"tags",
|
"tags",
|
||||||
"favorite",
|
"favorite",
|
||||||
"autoSync",
|
"autoSync",
|
||||||
|
"progressFromTasks",
|
||||||
"connectionId",
|
"connectionId",
|
||||||
] as const) {
|
] as const) {
|
||||||
if (data[key] !== undefined) update[key] = data[key];
|
if (data[key] !== undefined) update[key] = data[key];
|
||||||
@@ -94,9 +96,16 @@ export async function PATCH(request: Request, { params }: Params) {
|
|||||||
if (data.repoOwner !== undefined) update.repoOwner = data.repoOwner;
|
if (data.repoOwner !== undefined) update.repoOwner = data.repoOwner;
|
||||||
if (data.repoName !== undefined) update.repoName = data.repoName;
|
if (data.repoName !== undefined) update.repoName = data.repoName;
|
||||||
|
|
||||||
const project = await prisma.project.update({
|
await prisma.project.update({ where: { id }, data: update });
|
||||||
|
|
||||||
|
// Wird die Ableitung eingeschaltet, soll der Wert sofort stimmen und nicht
|
||||||
|
// erst beim naechsten Aufgabenwechsel.
|
||||||
|
if (data.progressFromTasks === true) {
|
||||||
|
await refreshDerivedProgress(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
const project = await prisma.project.findUniqueOrThrow({
|
||||||
where: { id },
|
where: { id },
|
||||||
data: update,
|
|
||||||
include: projectListInclude,
|
include: projectListInclude,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user