feat: sprints with burndown and carry-over
Plan sprints with dates and a goal, run one at a time per project, and put tickets in them from the ticket page. The Sprints tab follows the one under way with its progress and a burndown in tickets or points against the ideal line. Closing a sprint sends what was left to the next one or back to the backlog; the board can be filtered by sprint. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -6,6 +6,7 @@ import {
|
||||
NotificationKind,
|
||||
ProjectRole,
|
||||
ReleaseStatus,
|
||||
SprintStatus,
|
||||
StatusCategory,
|
||||
} from '@task-stream/api/tracker/domain';
|
||||
|
||||
@@ -23,6 +24,10 @@ registerEnumType(StatusCategory, {
|
||||
registerEnumType(IssueLinkType, { name: 'IssueLinkType' });
|
||||
registerEnumType(ProjectRole, { name: 'ProjectRole' });
|
||||
registerEnumType(ReleaseStatus, { name: 'ReleaseStatus' });
|
||||
registerEnumType(SprintStatus, {
|
||||
name: 'SprintStatus',
|
||||
description: 'PLANNED, ACTIVE (one per project at a time) or CLOSED',
|
||||
});
|
||||
registerEnumType(LinkDirection, { name: 'LinkDirection' });
|
||||
registerEnumType(IssueSort, {
|
||||
name: 'IssueSort',
|
||||
|
||||
@@ -181,6 +181,41 @@ export class ChangeIssueStatusInput {
|
||||
reason?: string | null;
|
||||
}
|
||||
|
||||
const DAY = /^\d{4}-\d{2}-\d{2}$/;
|
||||
|
||||
@InputType()
|
||||
export class CreateSprintInput {
|
||||
@Field(() => ID) @IsUUID() projectId!: string;
|
||||
@Field() @IsString() @MinLength(1) @MaxLength(80) name!: string;
|
||||
@Field(() => String, { nullable: true })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@MaxLength(500)
|
||||
goal?: string | null;
|
||||
@Field({ description: 'YYYY-MM-DD' }) @Matches(DAY) startDate!: string;
|
||||
@Field({ description: 'YYYY-MM-DD, included' })
|
||||
@Matches(DAY)
|
||||
endDate!: string;
|
||||
}
|
||||
|
||||
@InputType()
|
||||
export class UpdateSprintInput {
|
||||
@Field(() => ID) @IsUUID() sprintId!: string;
|
||||
@Field({ nullable: true })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@MinLength(1)
|
||||
@MaxLength(80)
|
||||
name?: string;
|
||||
@Field(() => String, { nullable: true })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@MaxLength(500)
|
||||
goal?: string | null;
|
||||
@Field({ nullable: true }) @IsOptional() @Matches(DAY) startDate?: string;
|
||||
@Field({ nullable: true }) @IsOptional() @Matches(DAY) endDate?: string;
|
||||
}
|
||||
|
||||
@InputType()
|
||||
export class SavedFilterCriteriaInput {
|
||||
@Field(() => [String], { nullable: true })
|
||||
@@ -320,6 +355,14 @@ export class IssueFilterInput {
|
||||
@IsOptional()
|
||||
@IsUUID()
|
||||
parentId?: string;
|
||||
@Field(() => ID, { nullable: true })
|
||||
@IsOptional()
|
||||
@IsUUID()
|
||||
sprintId?: string;
|
||||
@Field({ nullable: true, description: 'Only tickets in no sprint' })
|
||||
@IsOptional()
|
||||
@IsBoolean()
|
||||
noSprint?: boolean;
|
||||
@Field(() => IssueSort, { nullable: true, defaultValue: IssueSort.RECENT })
|
||||
@IsOptional()
|
||||
@IsEnum(IssueSort)
|
||||
|
||||
@@ -125,6 +125,8 @@ export class ProjectResolver {
|
||||
search?: string | null,
|
||||
@Args('unassigned', { type: () => Boolean, nullable: true })
|
||||
unassigned?: boolean | null,
|
||||
@Args('sprintId', { type: () => ID, nullable: true })
|
||||
sprintId?: string | null,
|
||||
) {
|
||||
return this.projects.board(
|
||||
viewerOf(me),
|
||||
@@ -138,6 +140,7 @@ export class ProjectResolver {
|
||||
labels: labels ?? undefined,
|
||||
search: search?.slice(0, 200) ?? undefined,
|
||||
unassigned: unassigned ?? undefined,
|
||||
sprintId: sprintId ?? undefined,
|
||||
},
|
||||
perColumn,
|
||||
);
|
||||
|
||||
170
libs/api/tracker/presenters/src/lib/graphql/sprint.resolver.ts
Normal file
170
libs/api/tracker/presenters/src/lib/graphql/sprint.resolver.ts
Normal file
@@ -0,0 +1,170 @@
|
||||
import {
|
||||
Args,
|
||||
ID,
|
||||
Int,
|
||||
Mutation,
|
||||
Parent,
|
||||
Query,
|
||||
ResolveField,
|
||||
Resolver,
|
||||
} from '@nestjs/graphql';
|
||||
import { User } from '@task-stream/api/identity/domain';
|
||||
import {
|
||||
CurrentUser,
|
||||
OptionalAuth,
|
||||
} from '@task-stream/api/identity/presenters';
|
||||
import {
|
||||
IssuesService,
|
||||
IssueSort,
|
||||
SprintsService,
|
||||
} from '@task-stream/api/tracker/application';
|
||||
import { SprintReadModel } from '@task-stream/api/tracker/domain';
|
||||
import { viewerOf } from '../common/viewer';
|
||||
import { CreateSprintInput, UpdateSprintInput } from './inputs';
|
||||
import {
|
||||
CommandResultGql,
|
||||
IssuePageGql,
|
||||
SprintBurndownGql,
|
||||
SprintGql,
|
||||
SprintProgressGql,
|
||||
} from './types';
|
||||
|
||||
@Resolver(() => SprintGql)
|
||||
export class SprintResolver {
|
||||
constructor(
|
||||
private readonly sprintsService: SprintsService,
|
||||
private readonly issuesService: IssuesService,
|
||||
) {}
|
||||
|
||||
@OptionalAuth()
|
||||
@Query(() => [SprintGql], {
|
||||
description:
|
||||
"A project's sprints: the one under way, the planned ones, then the closed ones",
|
||||
})
|
||||
sprints(
|
||||
@CurrentUser() me: User | undefined,
|
||||
@Args('projectId', { type: () => ID }) projectId: string,
|
||||
) {
|
||||
return this.sprintsService.list(viewerOf(me), projectId);
|
||||
}
|
||||
|
||||
@OptionalAuth()
|
||||
@Query(() => SprintGql)
|
||||
sprint(
|
||||
@CurrentUser() me: User | undefined,
|
||||
@Args('id', { type: () => ID }) id: string,
|
||||
) {
|
||||
return this.sprintsService.findOne(viewerOf(me), id);
|
||||
}
|
||||
|
||||
@ResolveField(() => SprintProgressGql)
|
||||
progress(
|
||||
@CurrentUser() me: User | undefined,
|
||||
@Parent() sprint: SprintReadModel,
|
||||
) {
|
||||
return this.sprintsService.progress(viewerOf(me), sprint.id);
|
||||
}
|
||||
|
||||
@ResolveField(() => SprintBurndownGql)
|
||||
burndown(
|
||||
@CurrentUser() me: User | undefined,
|
||||
@Parent() sprint: SprintReadModel,
|
||||
) {
|
||||
return this.sprintsService.burndown(viewerOf(me), sprint.id);
|
||||
}
|
||||
|
||||
@ResolveField(() => IssuePageGql, {
|
||||
description: 'Tickets in this sprint, in backlog order',
|
||||
})
|
||||
issues(
|
||||
@CurrentUser() me: User | undefined,
|
||||
@Parent() sprint: SprintReadModel,
|
||||
@Args('limit', { type: () => Int, defaultValue: 100 }) limit: number,
|
||||
@Args('offset', { type: () => Int, defaultValue: 0 }) offset: number,
|
||||
) {
|
||||
return this.issuesService.search(viewerOf(me), {
|
||||
projectId: sprint.projectId,
|
||||
sprintId: sprint.id,
|
||||
sort: IssueSort.RANK,
|
||||
limit,
|
||||
offset,
|
||||
});
|
||||
}
|
||||
|
||||
@Mutation(() => CommandResultGql, {
|
||||
description: 'Plan a sprint (owners and admins)',
|
||||
})
|
||||
createSprint(
|
||||
@CurrentUser() me: User,
|
||||
@Args('input') input: CreateSprintInput,
|
||||
) {
|
||||
return this.sprintsService.create(me.id, input);
|
||||
}
|
||||
|
||||
@Mutation(() => CommandResultGql)
|
||||
updateSprint(
|
||||
@CurrentUser() me: User,
|
||||
@Args('input') input: UpdateSprintInput,
|
||||
) {
|
||||
const { sprintId, ...changes } = input;
|
||||
return this.sprintsService.update(
|
||||
me.id,
|
||||
sprintId,
|
||||
Object.fromEntries(
|
||||
Object.entries(changes).filter(
|
||||
([field, value]) => value !== null || field === 'goal',
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@Mutation(() => CommandResultGql, {
|
||||
description: 'Start a planned sprint (only one under way per project)',
|
||||
})
|
||||
startSprint(
|
||||
@CurrentUser() me: User,
|
||||
@Args('sprintId', { type: () => ID }) sprintId: string,
|
||||
) {
|
||||
return this.sprintsService.start(me.id, sprintId);
|
||||
}
|
||||
|
||||
@Mutation(() => CommandResultGql, {
|
||||
description:
|
||||
'Close the sprint under way. Unfinished tickets move to carryOverToSprintId, or back to the backlog when it is null.',
|
||||
})
|
||||
closeSprint(
|
||||
@CurrentUser() me: User,
|
||||
@Args('sprintId', { type: () => ID }) sprintId: string,
|
||||
@Args('carryOverToSprintId', { type: () => ID, nullable: true })
|
||||
carryOverToSprintId: string | null,
|
||||
) {
|
||||
return this.sprintsService.close(
|
||||
me.id,
|
||||
sprintId,
|
||||
carryOverToSprintId ?? null,
|
||||
);
|
||||
}
|
||||
|
||||
@Mutation(() => CommandResultGql, {
|
||||
description:
|
||||
'Delete a sprint that never started; its tickets go back to the backlog',
|
||||
})
|
||||
deleteSprint(
|
||||
@CurrentUser() me: User,
|
||||
@Args('sprintId', { type: () => ID }) sprintId: string,
|
||||
) {
|
||||
return this.sprintsService.delete(me.id, sprintId);
|
||||
}
|
||||
|
||||
@Mutation(() => CommandResultGql, {
|
||||
description: 'Put a ticket in a sprint (null: back to the backlog)',
|
||||
})
|
||||
setIssueSprint(
|
||||
@CurrentUser() me: User,
|
||||
@Args('issueId', { type: () => ID }) issueId: string,
|
||||
@Args('sprintId', { type: () => ID, nullable: true })
|
||||
sprintId: string | null,
|
||||
) {
|
||||
return this.sprintsService.setIssueSprint(me.id, issueId, sprintId ?? null);
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
NotificationGql,
|
||||
ProjectChangeGql,
|
||||
ReleaseChangeGql,
|
||||
SprintChangeGql,
|
||||
} from './types';
|
||||
|
||||
const asIs = { resolve: <T>(payload: T) => payload };
|
||||
@@ -66,6 +67,14 @@ export class SubscriptionResolver {
|
||||
return this.changes.watchReleases(me.id, projectId);
|
||||
}
|
||||
|
||||
@Subscription(() => SprintChangeGql, asIs)
|
||||
sprintChanged(
|
||||
@CurrentUser() me: User,
|
||||
@Args('projectId', { type: () => ID }) projectId: string,
|
||||
) {
|
||||
return this.changes.watchSprints(me.id, projectId);
|
||||
}
|
||||
|
||||
@Subscription(() => ProjectChangeGql, asIs)
|
||||
projectChanged(
|
||||
@CurrentUser() me: User,
|
||||
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
NotificationKind,
|
||||
ProjectRole,
|
||||
ReleaseStatus,
|
||||
SprintStatus,
|
||||
StatusCategory,
|
||||
} from '@task-stream/api/tracker/domain';
|
||||
import { LinkDirection } from './enums';
|
||||
@@ -110,6 +111,12 @@ export class AttachmentGql {
|
||||
commentId!: string | null;
|
||||
}
|
||||
|
||||
@ObjectType('SprintRef')
|
||||
export class SprintRefGql {
|
||||
@Field(() => ID) id!: string;
|
||||
@Field() name!: string;
|
||||
}
|
||||
|
||||
@ObjectType('ReleaseRef')
|
||||
export class ReleaseRefGql {
|
||||
@Field(() => ID) id!: string;
|
||||
@@ -154,6 +161,7 @@ export class IssueGql {
|
||||
@Field(() => UserRefGql, { nullable: true }) assignee!: UserRefGql | null;
|
||||
@Field(() => ReleaseRefGql, { nullable: true })
|
||||
release!: ReleaseRefGql | null;
|
||||
@Field(() => SprintRefGql, { nullable: true }) sprint!: SprintRefGql | null;
|
||||
@Field(() => [String]) labels!: string[];
|
||||
@Field(() => String, { nullable: true }) figmaUrl!: string | null;
|
||||
@Field(() => Int, { nullable: true }) storyPoints!: number | null;
|
||||
@@ -270,6 +278,56 @@ export class ReleaseGql {
|
||||
@Field(() => Int) version!: number;
|
||||
}
|
||||
|
||||
@ObjectType('Sprint', {
|
||||
description: 'A time-boxed iteration: the tickets the team commits to',
|
||||
})
|
||||
export class SprintGql {
|
||||
@Field(() => ID) id!: string;
|
||||
@Field(() => ID) projectId!: string;
|
||||
@Field() name!: string;
|
||||
@Field(() => String, { nullable: true }) goal!: string | null;
|
||||
@Field({ description: 'First day, YYYY-MM-DD' }) startDate!: string;
|
||||
@Field({ description: 'Last day (included), YYYY-MM-DD' }) endDate!: string;
|
||||
@Field(() => SprintStatus) status!: SprintStatus;
|
||||
@Field(() => String, { nullable: true }) startedAt!: string | null;
|
||||
@Field(() => String, { nullable: true }) closedAt!: string | null;
|
||||
@Field() createdAt!: string;
|
||||
@Field(() => Int) version!: number;
|
||||
}
|
||||
|
||||
@ObjectType('SprintProgress')
|
||||
export class SprintProgressGql {
|
||||
@Field(() => Int) total!: number;
|
||||
@Field(() => Int, { description: 'Done or cancelled' }) finished!: number;
|
||||
@Field(() => Int) percent!: number;
|
||||
@Field(() => Int) storyPoints!: number;
|
||||
@Field(() => Int) finishedStoryPoints!: number;
|
||||
}
|
||||
|
||||
@ObjectType('SprintBurndown', {
|
||||
description:
|
||||
'Per day of the sprint: tickets in it, still open, and their points (null: days to come). `ideal` falls from the first day to zero.',
|
||||
})
|
||||
export class SprintBurndownGql {
|
||||
@Field(() => ID) sprintId!: string;
|
||||
@Field(() => [String]) dates!: string[];
|
||||
@Field(() => [Int], { nullable: 'items' }) scope!: (number | null)[];
|
||||
@Field(() => [Int], { nullable: 'items' }) remaining!: (number | null)[];
|
||||
@Field(() => [Int], { nullable: 'items' })
|
||||
remainingPoints!: (number | null)[];
|
||||
@Field(() => [Float]) ideal!: number[];
|
||||
}
|
||||
|
||||
@ObjectType('SprintChange')
|
||||
export class SprintChangeGql {
|
||||
@Field() action!: string;
|
||||
@Field(() => Int) version!: number;
|
||||
@Field(() => ID) actorId!: string;
|
||||
@Field(() => ID) sprintId!: string;
|
||||
@Field(() => SprintGql, { nullable: true, description: 'Null: deleted' })
|
||||
sprint!: SprintGql | null;
|
||||
}
|
||||
|
||||
@ObjectType('CountByStatus')
|
||||
export class CountByStatusGql {
|
||||
@Field({ description: 'Status id' }) key!: string;
|
||||
|
||||
@@ -285,6 +285,11 @@ export class BoardQueryDto {
|
||||
@IsBoolean()
|
||||
unassigned?: boolean;
|
||||
|
||||
@ApiPropertyOptional({ format: 'uuid', description: 'Only this sprint' })
|
||||
@IsOptional()
|
||||
@IsUUID()
|
||||
sprintId?: string;
|
||||
|
||||
@ApiPropertyOptional({ type: Number, default: 50, minimum: 1, maximum: 200 })
|
||||
@IsOptional()
|
||||
@Type(() => Number)
|
||||
@@ -451,6 +456,17 @@ export class IssueSearchQueryDto extends PageQueryDto {
|
||||
@IsString()
|
||||
parent?: string;
|
||||
|
||||
@ApiPropertyOptional({ format: 'uuid', description: 'Only this sprint' })
|
||||
@IsOptional()
|
||||
@IsUUID()
|
||||
sprintId?: string;
|
||||
|
||||
@ApiPropertyOptional({ description: 'Only tickets in no sprint' })
|
||||
@IsOptional()
|
||||
@Transform(toBoolean)
|
||||
@IsBoolean()
|
||||
noSprint?: boolean;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
enum: IssueSort,
|
||||
enumName: 'IssueSort',
|
||||
@@ -819,6 +835,66 @@ export class CreateReleaseDto {
|
||||
|
||||
export class UpdateReleaseDto extends PartialType(CreateReleaseDto) {}
|
||||
|
||||
const DAY = /^\d{4}-\d{2}-\d{2}$/;
|
||||
|
||||
export class CreateSprintDto {
|
||||
@ApiProperty({ example: 'Sprint 14', maxLength: 80 })
|
||||
@IsString()
|
||||
@MinLength(1)
|
||||
@MaxLength(80)
|
||||
name!: string;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
type: String,
|
||||
nullable: true,
|
||||
maxLength: 500,
|
||||
example: 'Pagos con tarjeta en producción',
|
||||
})
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@MaxLength(500)
|
||||
goal?: string | null;
|
||||
|
||||
@ApiProperty({ format: 'date', example: '2026-10-12' })
|
||||
@Matches(DAY)
|
||||
startDate!: string;
|
||||
|
||||
@ApiProperty({
|
||||
format: 'date',
|
||||
example: '2026-10-23',
|
||||
description: 'Last day, included',
|
||||
})
|
||||
@Matches(DAY)
|
||||
endDate!: string;
|
||||
}
|
||||
|
||||
export class UpdateSprintDto extends PartialType(CreateSprintDto) {}
|
||||
|
||||
export class CloseSprintDto {
|
||||
@ApiPropertyOptional({
|
||||
type: String,
|
||||
nullable: true,
|
||||
format: 'uuid',
|
||||
description:
|
||||
'Open sprint of the same project that takes the unfinished tickets; null or absent: back to the backlog',
|
||||
})
|
||||
@IsOptional()
|
||||
@IsUUID()
|
||||
carryOverTo?: string | null;
|
||||
}
|
||||
|
||||
export class SetIssueSprintDto {
|
||||
@ApiProperty({
|
||||
type: String,
|
||||
nullable: true,
|
||||
format: 'uuid',
|
||||
description: 'Open sprint of the project, or null for the backlog',
|
||||
})
|
||||
@ValidateIf((dto: SetIssueSprintDto) => dto.sprintId !== null)
|
||||
@IsUUID()
|
||||
sprintId!: string | null;
|
||||
}
|
||||
|
||||
export class PublishReleaseDto {
|
||||
@ApiPropertyOptional({
|
||||
type: Boolean,
|
||||
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
NotificationKind,
|
||||
ProjectRole,
|
||||
ReleaseStatus,
|
||||
SprintStatus,
|
||||
SETTING_COLORS,
|
||||
StatusCategory,
|
||||
TYPE_ICONS,
|
||||
@@ -135,6 +136,11 @@ export class IssueParentDto {
|
||||
@ApiProperty({ example: 'Pago con tarjeta' }) title!: string;
|
||||
}
|
||||
|
||||
export class SprintRefDto {
|
||||
@ApiProperty({ format: 'uuid' }) id!: string;
|
||||
@ApiProperty({ example: 'Sprint 14' }) name!: string;
|
||||
}
|
||||
|
||||
export class IssueDto {
|
||||
@ApiProperty({ format: 'uuid' }) id!: string;
|
||||
@ApiProperty({ format: 'uuid' }) projectId!: string;
|
||||
@@ -163,6 +169,8 @@ export class IssueDto {
|
||||
assignee!: UserRefDto | null;
|
||||
@ApiProperty({ type: ReleaseRefDto, nullable: true })
|
||||
release!: ReleaseRefDto | null;
|
||||
@ApiProperty({ type: SprintRefDto, nullable: true })
|
||||
sprint!: SprintRefDto | null;
|
||||
@ApiProperty({ type: [String] }) labels!: string[];
|
||||
@ApiProperty({ type: String, nullable: true, description: 'Figma frame' })
|
||||
figmaUrl!: string | null;
|
||||
@@ -255,6 +263,50 @@ export class CommentPageDto {
|
||||
@ApiProperty() total!: number;
|
||||
}
|
||||
|
||||
export class SprintDto {
|
||||
@ApiProperty({ format: 'uuid' }) id!: string;
|
||||
@ApiProperty({ format: 'uuid' }) projectId!: string;
|
||||
@ApiProperty({ example: 'Sprint 14' }) name!: string;
|
||||
@ApiProperty({ type: String, nullable: true }) goal!: string | null;
|
||||
@ApiProperty({ format: 'date' }) startDate!: string;
|
||||
@ApiProperty({ format: 'date', description: 'Last day, included' })
|
||||
endDate!: string;
|
||||
@ApiProperty({ enum: SprintStatus, enumName: 'SprintStatus' })
|
||||
status!: SprintStatus;
|
||||
@ApiProperty({ type: String, nullable: true, format: 'date-time' })
|
||||
startedAt!: string | null;
|
||||
@ApiProperty({ type: String, nullable: true, format: 'date-time' })
|
||||
closedAt!: string | null;
|
||||
@ApiProperty({ format: 'date-time' }) createdAt!: string;
|
||||
@ApiProperty() version!: number;
|
||||
}
|
||||
|
||||
export class SprintProgressDto {
|
||||
@ApiProperty() total!: number;
|
||||
@ApiProperty({ description: 'Done or cancelled' }) finished!: number;
|
||||
@ApiProperty({ minimum: 0, maximum: 100 }) percent!: number;
|
||||
@ApiProperty() storyPoints!: number;
|
||||
@ApiProperty() finishedStoryPoints!: number;
|
||||
}
|
||||
|
||||
export class SprintBurndownDto {
|
||||
@ApiProperty({ format: 'uuid' }) sprintId!: string;
|
||||
@ApiProperty({ type: [String], format: 'date' }) dates!: string[];
|
||||
@ApiProperty({
|
||||
type: [Number],
|
||||
nullable: true,
|
||||
description: 'Tickets in the sprint (null: days to come)',
|
||||
})
|
||||
scope!: (number | null)[];
|
||||
@ApiProperty({ type: [Number], nullable: true }) remaining!: (
|
||||
| number
|
||||
| null
|
||||
)[];
|
||||
@ApiProperty({ type: [Number], nullable: true })
|
||||
remainingPoints!: (number | null)[];
|
||||
@ApiProperty({ type: [Number] }) ideal!: number[];
|
||||
}
|
||||
|
||||
export class ReleaseDto {
|
||||
@ApiProperty({ format: 'uuid' }) id!: string;
|
||||
@ApiProperty({ format: 'uuid' }) projectId!: string;
|
||||
|
||||
@@ -157,6 +157,8 @@ export class IssuesController {
|
||||
unassigned: query.unassigned,
|
||||
releaseId: query.releaseId,
|
||||
labels: query.label,
|
||||
sprintId: query.sprintId,
|
||||
noSprint: query.noSprint,
|
||||
sort: query.sort,
|
||||
search: query.search,
|
||||
limit: query.limit,
|
||||
|
||||
@@ -187,6 +187,7 @@ export class ProjectsController {
|
||||
labels: query.label,
|
||||
search: query.search,
|
||||
unassigned: query.unassigned,
|
||||
sprintId: query.sprintId,
|
||||
},
|
||||
query.perColumn,
|
||||
);
|
||||
|
||||
249
libs/api/tracker/presenters/src/lib/http/sprints.controller.ts
Normal file
249
libs/api/tracker/presenters/src/lib/http/sprints.controller.ts
Normal file
@@ -0,0 +1,249 @@
|
||||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Get,
|
||||
Param,
|
||||
ParseUUIDPipe,
|
||||
Patch,
|
||||
Post,
|
||||
Put,
|
||||
Query,
|
||||
} from '@nestjs/common';
|
||||
import {
|
||||
ApiCreatedResponse,
|
||||
ApiOkResponse,
|
||||
ApiOperation,
|
||||
ApiParam,
|
||||
ApiTags,
|
||||
} from '@nestjs/swagger';
|
||||
import { User } from '@task-stream/api/identity/domain';
|
||||
import {
|
||||
ApiOptionalPireonAuth,
|
||||
ApiPireonAuth,
|
||||
CurrentUser,
|
||||
} from '@task-stream/api/identity/presenters';
|
||||
import {
|
||||
ApiCommandErrors,
|
||||
ApiReadErrors,
|
||||
} from '@task-stream/api/shared/presenters';
|
||||
import {
|
||||
IssuesService,
|
||||
IssueSort,
|
||||
SprintsService,
|
||||
} from '@task-stream/api/tracker/application';
|
||||
import { viewerOf } from '../common/viewer';
|
||||
import {
|
||||
CloseSprintDto,
|
||||
CreateSprintDto,
|
||||
PageQueryDto,
|
||||
SetIssueSprintDto,
|
||||
UpdateSprintDto,
|
||||
} from './dto/requests.dto';
|
||||
import {
|
||||
CommandResultDto,
|
||||
IssuePageDto,
|
||||
SprintBurndownDto,
|
||||
SprintDto,
|
||||
SprintProgressDto,
|
||||
} from './dto/responses.dto';
|
||||
import { Refs } from './refs';
|
||||
|
||||
const PROJECT = ApiParam({
|
||||
name: 'project',
|
||||
description: 'Project id or key',
|
||||
example: 'WEB',
|
||||
});
|
||||
const SPRINT = ApiParam({ name: 'sprint', format: 'uuid' });
|
||||
|
||||
/** REST adapter of the sprint use cases: plan, run and close iterations. */
|
||||
@ApiTags('Sprints')
|
||||
@ApiPireonAuth()
|
||||
@Controller()
|
||||
export class SprintsController {
|
||||
constructor(
|
||||
private readonly sprints: SprintsService,
|
||||
private readonly issues: IssuesService,
|
||||
private readonly refs: Refs,
|
||||
) {}
|
||||
|
||||
@Get('projects/:project/sprints')
|
||||
@ApiOptionalPireonAuth()
|
||||
@PROJECT
|
||||
@ApiOperation({
|
||||
summary: "A project's sprints",
|
||||
description: 'The one under way, the planned ones, then the closed ones.',
|
||||
})
|
||||
@ApiOkResponse({ type: [SprintDto] })
|
||||
@ApiReadErrors()
|
||||
async list(
|
||||
@CurrentUser() me: User | undefined,
|
||||
@Param('project') project: string,
|
||||
) {
|
||||
return this.sprints.list(
|
||||
viewerOf(me),
|
||||
await this.refs.projectId(viewerOf(me), project),
|
||||
);
|
||||
}
|
||||
|
||||
@Post('projects/:project/sprints')
|
||||
@PROJECT
|
||||
@ApiOperation({ summary: 'Plan a sprint (owners and admins)' })
|
||||
@ApiCreatedResponse({ type: CommandResultDto })
|
||||
@ApiCommandErrors()
|
||||
async create(
|
||||
@CurrentUser() me: User,
|
||||
@Param('project') project: string,
|
||||
@Body() body: CreateSprintDto,
|
||||
) {
|
||||
return this.sprints.create(me.id, {
|
||||
...body,
|
||||
projectId: await this.refs.projectId(me.id, project),
|
||||
});
|
||||
}
|
||||
|
||||
@Get('sprints/:sprint')
|
||||
@ApiOptionalPireonAuth()
|
||||
@SPRINT
|
||||
@ApiOperation({ summary: 'A sprint' })
|
||||
@ApiOkResponse({ type: SprintDto })
|
||||
@ApiReadErrors()
|
||||
findOne(
|
||||
@CurrentUser() me: User | undefined,
|
||||
@Param('sprint', ParseUUIDPipe) sprint: string,
|
||||
) {
|
||||
return this.sprints.findOne(viewerOf(me), sprint);
|
||||
}
|
||||
|
||||
@Patch('sprints/:sprint')
|
||||
@SPRINT
|
||||
@ApiOperation({
|
||||
summary: 'Rename, re-date or change the goal (not once closed)',
|
||||
})
|
||||
@ApiOkResponse({ type: CommandResultDto })
|
||||
@ApiCommandErrors()
|
||||
update(
|
||||
@CurrentUser() me: User,
|
||||
@Param('sprint', ParseUUIDPipe) sprint: string,
|
||||
@Body() body: UpdateSprintDto,
|
||||
) {
|
||||
return this.sprints.update(me.id, sprint, body);
|
||||
}
|
||||
|
||||
@Delete('sprints/:sprint')
|
||||
@SPRINT
|
||||
@ApiOperation({
|
||||
summary: 'Delete a sprint that never started',
|
||||
description: 'Its tickets go back to the backlog.',
|
||||
})
|
||||
@ApiOkResponse({ type: CommandResultDto })
|
||||
@ApiCommandErrors()
|
||||
delete(
|
||||
@CurrentUser() me: User,
|
||||
@Param('sprint', ParseUUIDPipe) sprint: string,
|
||||
) {
|
||||
return this.sprints.delete(me.id, sprint);
|
||||
}
|
||||
|
||||
@Post('sprints/:sprint/start')
|
||||
@SPRINT
|
||||
@ApiOperation({
|
||||
summary: 'Start a planned sprint (only one under way per project)',
|
||||
})
|
||||
@ApiCreatedResponse({ type: CommandResultDto })
|
||||
@ApiCommandErrors()
|
||||
start(
|
||||
@CurrentUser() me: User,
|
||||
@Param('sprint', ParseUUIDPipe) sprint: string,
|
||||
) {
|
||||
return this.sprints.start(me.id, sprint);
|
||||
}
|
||||
|
||||
@Post('sprints/:sprint/close')
|
||||
@SPRINT
|
||||
@ApiOperation({
|
||||
summary: 'Close the sprint under way',
|
||||
description:
|
||||
'Unfinished tickets move to `carryOverTo` (another open sprint) or back to the backlog; finished ones stay as its record.',
|
||||
})
|
||||
@ApiCreatedResponse({ type: CommandResultDto })
|
||||
@ApiCommandErrors()
|
||||
close(
|
||||
@CurrentUser() me: User,
|
||||
@Param('sprint', ParseUUIDPipe) sprint: string,
|
||||
@Body() body: CloseSprintDto,
|
||||
) {
|
||||
return this.sprints.close(me.id, sprint, body.carryOverTo ?? null);
|
||||
}
|
||||
|
||||
@Get('sprints/:sprint/progress')
|
||||
@ApiOptionalPireonAuth()
|
||||
@SPRINT
|
||||
@ApiOperation({ summary: 'Finished tickets and points' })
|
||||
@ApiOkResponse({ type: SprintProgressDto })
|
||||
@ApiReadErrors()
|
||||
progress(
|
||||
@CurrentUser() me: User | undefined,
|
||||
@Param('sprint', ParseUUIDPipe) sprint: string,
|
||||
) {
|
||||
return this.sprints.progress(viewerOf(me), sprint);
|
||||
}
|
||||
|
||||
@Get('sprints/:sprint/burndown')
|
||||
@ApiOptionalPireonAuth()
|
||||
@SPRINT
|
||||
@ApiOperation({
|
||||
summary: 'Open tickets and points, day by day, against the ideal line',
|
||||
})
|
||||
@ApiOkResponse({ type: SprintBurndownDto })
|
||||
@ApiReadErrors()
|
||||
burndown(
|
||||
@CurrentUser() me: User | undefined,
|
||||
@Param('sprint', ParseUUIDPipe) sprint: string,
|
||||
) {
|
||||
return this.sprints.burndown(viewerOf(me), sprint);
|
||||
}
|
||||
|
||||
@Get('sprints/:sprint/issues')
|
||||
@ApiOptionalPireonAuth()
|
||||
@SPRINT
|
||||
@ApiOperation({ summary: 'Tickets in the sprint, in backlog order' })
|
||||
@ApiOkResponse({ type: IssuePageDto })
|
||||
@ApiReadErrors()
|
||||
async issuesOf(
|
||||
@CurrentUser() me: User | undefined,
|
||||
@Param('sprint', ParseUUIDPipe) sprint: string,
|
||||
@Query() query: PageQueryDto,
|
||||
) {
|
||||
const found = await this.sprints.findOne(viewerOf(me), sprint);
|
||||
const page = await this.issues.search(viewerOf(me), {
|
||||
projectId: found.projectId,
|
||||
sprintId: found.id,
|
||||
sort: IssueSort.RANK,
|
||||
limit: query.limit,
|
||||
offset: query.offset,
|
||||
});
|
||||
return { ...page, items: await this.refs.issueDtos(page.items) };
|
||||
}
|
||||
|
||||
@Put('issues/:issue/sprint')
|
||||
@ApiParam({
|
||||
name: 'issue',
|
||||
description: 'Ticket id or key',
|
||||
example: 'WEB-12',
|
||||
})
|
||||
@ApiOperation({ summary: 'Put the ticket in a sprint (null: the backlog)' })
|
||||
@ApiOkResponse({ type: CommandResultDto })
|
||||
@ApiCommandErrors()
|
||||
async setIssueSprint(
|
||||
@CurrentUser() me: User,
|
||||
@Param('issue') issue: string,
|
||||
@Body() body: SetIssueSprintDto,
|
||||
) {
|
||||
return this.sprints.setIssueSprint(
|
||||
me.id,
|
||||
await this.refs.issueId(me.id, issue),
|
||||
body.sprintId,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,8 @@ import { ReleasesController } from './http/releases.controller';
|
||||
import { NotificationsController } from './http/notifications.controller';
|
||||
import { SavedFiltersController } from './http/saved-filters.controller';
|
||||
import { SavedFilterResolver } from './graphql/saved-filter.resolver';
|
||||
import { SprintResolver } from './graphql/sprint.resolver';
|
||||
import { SprintsController } from './http/sprints.controller';
|
||||
|
||||
/**
|
||||
* Driving adapters of the tracker context: GraphQL (queries, mutations,
|
||||
@@ -48,6 +50,7 @@ import { SavedFilterResolver } from './graphql/saved-filter.resolver';
|
||||
ExploreController,
|
||||
NotificationsController,
|
||||
SavedFiltersController,
|
||||
SprintsController,
|
||||
],
|
||||
providers: [
|
||||
Refs,
|
||||
@@ -58,6 +61,7 @@ import { SavedFilterResolver } from './graphql/saved-filter.resolver';
|
||||
SubscriptionResolver,
|
||||
NotificationResolver,
|
||||
SavedFilterResolver,
|
||||
SprintResolver,
|
||||
],
|
||||
})
|
||||
export class TrackerPresentersModule {
|
||||
|
||||
Reference in New Issue
Block a user