Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions apps/job-service/src/jobs/delayed-jobs.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,12 @@ describe("DelayedJobsController", () => {
data: [
{
type: "delayedJobs",
uuid: job1.uuid,
id: job1.uuid,
attributes: { isAcknowledged: true }
},
{
type: "delayedJobs",
uuid: job2.uuid,
id: job2.uuid,
attributes: { isAcknowledged: true }
}
]
Expand Down Expand Up @@ -147,12 +147,12 @@ describe("DelayedJobsController", () => {
data: [
{
type: "delayedJobs",
uuid: job1.uuid,
id: job1.uuid,
attributes: { isAcknowledged: true }
},
{
type: "delayedJobs",
uuid: job2.uuid,
id: job2.uuid,
attributes: { isAcknowledged: true }
}
]
Expand All @@ -178,7 +178,7 @@ describe("DelayedJobsController", () => {
data: [
{
type: "delayedJobs",
uuid: "non-existent-uuid",
id: "non-existent-uuid",
attributes: { isAcknowledged: true }
}
]
Expand Down Expand Up @@ -210,12 +210,12 @@ describe("DelayedJobsController", () => {
data: [
{
type: "delayedJobs",
uuid: pendingJob.uuid,
id: pendingJob.uuid,
attributes: { isAcknowledged: true }
},
{
type: "delayedJobs",
uuid: pendingJob2.uuid,
id: pendingJob2.uuid,
attributes: { isAcknowledged: true }
}
]
Expand Down Expand Up @@ -247,13 +247,13 @@ describe("DelayedJobsController", () => {
it("should validate nested DelayedJobAttributes", async () => {
const validData = {
type: "delayedJobs",
uuid: uuidv4(),
id: uuidv4(),
attributes: { isAcknowledged: true }
};

const invalidData = {
type: "delayedJobs",
uuid: uuidv4(),
id: uuidv4(),
attributes: {
isAcknowledged: "not a boolean"
}
Expand Down
8 changes: 4 additions & 4 deletions apps/job-service/src/jobs/delayed-jobs.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export class DelayedJobsController {
const jobUpdates = bulkUpdateJobsDto.data;
const jobs = await DelayedJob.findAll({
where: {
uuid: { [Op.in]: jobUpdates.map(({ uuid }) => uuid) },
uuid: { [Op.in]: jobUpdates.map(({ id }) => id) },
createdBy: authenticatedUserId
},
order: [["createdAt", "DESC"]]
Expand All @@ -91,9 +91,9 @@ export class DelayedJobsController {
const updatedJobs = (
await Promise.all(
jobUpdates
.filter(({ uuid }) => jobs.some(job => job.uuid === uuid))
.map(async ({ uuid, attributes }) => {
const job = jobs.find(job => job.uuid === uuid);
.filter(({ id }) => jobs.some(job => job.uuid === id))
.map(async ({ id, attributes }) => {
const job = jobs.find(job => job.uuid === id);
return await job?.update({ isAcknowledged: attributes.isAcknowledged });
})
)
Expand Down
7 changes: 4 additions & 3 deletions apps/job-service/src/jobs/dto/delayed-job-update.dto.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ApiProperty } from "@nestjs/swagger";
import { IsBoolean, IsUUID, ValidateNested } from "class-validator";
import { Equals, IsBoolean, IsUUID, ValidateNested } from "class-validator";
import { Type } from "class-transformer";
import { JsonApiBulkBodyDto } from "@terramatch-microservices/common/util/json-api-update-dto";

Expand All @@ -10,12 +10,13 @@ export class DelayedJobAttributes {
}

export class DelayedJobData {
@Equals("delayedJobs")
@ApiProperty({ enum: ["delayedJobs"], description: "Type of the resource", example: "delayedJobs" })
type: "delayedJobs";

@IsUUID()
@ApiProperty({ format: "uuid", description: "UUID of the job", example: "uuid-1" })
uuid: string;
@ApiProperty({ format: "uuid", description: "UUID of the job", example: "550e8400-e29b-41d4-a716-446655440000" })
id: string;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the data will be uuid or id ?
In the example it says that it will be uuid, then there is an inconsistency in the name as it is id.
I think the fix should be in other part in order to keep the correct matching between the data (uuid) and the naming of it.
I mean if UUID is the data, then the name should be UUID too.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The use of id is correct according to the JSON API. The format: uuid indicates the value format, not the field name.
Other DTOs in the project already use id with UUID values.
SitePolygonUpdate (line 42)
The frontend already sends id in the payload`.
In any case, I can try using UUIDs, but I think that would be a more complex solution for formatting it.

Copy link
Collaborator

@egrojMonroy egrojMonroy Dec 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but the Uuid name is from 12 months ago, that means that it was working good with uuid.
Maybe the error is in the frontend instead?
I think this error might have appeared since 445213a or this 66aacad but not sure


@ValidateNested()
@Type(() => DelayedJobAttributes)
Expand Down