Skip to content

Commit

Permalink
feat(jobs): implemented user job folders feature
Browse files Browse the repository at this point in the history
CLOSES: JOB-546
  • Loading branch information
AndySakov committed Mar 12, 2024
1 parent 403f177 commit ecb11e0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
16 changes: 7 additions & 9 deletions src/jobs/jobs.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,7 @@ describe("JobsController", () => {
expect(result).toEqual({
success: true,
message: expect.stringMatching("success"),
data: expect.any(JobpostFolder),
});

const details = await controller.getUserJobFolderById(
Expand All @@ -649,7 +650,11 @@ describe("JobsController", () => {
data(result).id,
);

expect(details).toStrictEqual(expect.any(JobpostFolder));
expect(details).toEqual({
success: true,
message: expect.stringMatching("success"),
data: expect.any(JobpostFolder),
});

jobFolderId = data(result).id;
},
Expand Down Expand Up @@ -686,15 +691,8 @@ describe("JobsController", () => {
expect(result).toEqual({
success: true,
message: expect.stringMatching("success"),
data: expect.any(JobpostFolder),
});

const details = await controller.getUserJobFolderById(
req as Request,
res as Response,
data(result).id,
);

expect(data(details)).toStrictEqual(expect.any(JobpostFolder));
},
REALLY_LONG_TIME,
);
Expand Down
17 changes: 11 additions & 6 deletions src/jobs/jobs.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1376,7 +1376,7 @@ export class JobsService {
const result = await this.neogma.queryRunner.run(
`
MATCH (folder: JobpostFolder {id: $id})
MATCH (folder)-[:CONTAINS_JOBPOST]->(structured_jobpost:StructuredJobpost)-[:HAS_STATUS]->(:JobpostOnlineStatus)
OPTIONAL MATCH (folder)-[:CONTAINS_JOBPOST]->(structured_jobpost:StructuredJobpost)-[:HAS_STATUS]->(:JobpostOnlineStatus)
WHERE NOT (structured_jobpost)-[:HAS_JOB_DESIGNATION]->(:BlockedDesignation)
CALL {
Expand Down Expand Up @@ -1545,7 +1545,7 @@ export class JobsService {
WITH folder
MATCH (job:StructuredJobpost WHERE job.shortUUID IN $jobs)
OPTIONAL MATCH (job:StructuredJobpost WHERE job.shortUUID IN $jobs)
CREATE (folder)-[:CONTAINS_JOBPOST]->(job)
RETURN folder { .* } as folder
Expand All @@ -1554,6 +1554,7 @@ export class JobsService {
);

const res = result.records[0]?.get("folder");

if (res) {
const details = data(await this.getUserJobFolderById(res.id));
return {
Expand Down Expand Up @@ -1591,15 +1592,19 @@ export class JobsService {
try {
const result = await this.neogma.queryRunner.run(
`
MATCH (folder:JobpostFolder {id: $id})-[r:CONTAINS_JOBPOST]->(:StructuredJobpost)
MATCH (folder:JobpostFolder {id: $id})
SET folder.name = $name
SET folder.isPublic = $isPublic
WITH folder
OPTIONAL MATCH (folder)-[r:CONTAINS_JOBPOST]->(:StructuredJobpost)
DETACH DELETE r
MATCH (job:StructuredJobpost WHERE job.shortUUID IN $jobs), (folder:JobpostFolder {id: $id})
WITH folder
OPTIONAL MATCH (job:StructuredJobpost WHERE job.shortUUID IN $jobs)
CREATE (folder)-[:CONTAINS_JOBPOST]->(job)
RETURN folder
RETURN folder { .* } as folder
`,
{ id, ...dto },
);
Expand Down Expand Up @@ -1640,7 +1645,7 @@ export class JobsService {
await this.neogma.queryRunner.run(
`
MATCH (folder:JobpostFolder {id: $id})
DETACH DELETE r
DETACH DELETE folder
`,
{ id },
);
Expand Down

0 comments on commit ecb11e0

Please sign in to comment.