Skip to content

Feat/add POST api endpoint for skill relation#501

Open
HabtamuTesafaye wants to merge 6 commits into
mainfrom
feat/add-POST-api-endpoint-for-skill-relation
Open

Feat/add POST api endpoint for skill relation#501
HabtamuTesafaye wants to merge 6 commits into
mainfrom
feat/add-POST-api-endpoint-for-skill-relation

Conversation

@HabtamuTesafaye

Copy link
Copy Markdown
Contributor

This pull request contains new POST api endpoint for skill relations

@HabtamuTesafaye HabtamuTesafaye self-assigned this Jun 9, 2026
@HabtamuTesafaye HabtamuTesafaye added the enhancement New feature or request label Jun 9, 2026
@HabtamuTesafaye HabtamuTesafaye changed the title Feat/add post api endpoint for skill relation Feat/add POST api endpoint for skill relation Jun 9, 2026
Comment thread backend/src/esco/skill/index.ts
@HabtamuTesafaye HabtamuTesafaye marked this pull request as draft June 10, 2026 06:09
@HabtamuTesafaye HabtamuTesafaye force-pushed the feat/add-POST-api-endpoint-for-skill-relation branch from da5611d to 88dd1f2 Compare June 17, 2026 12:10
@HabtamuTesafaye HabtamuTesafaye marked this pull request as ready for review June 17, 2026 13:14
@@ -0,0 +1,246 @@
import { SkillToSkillRelationService } from "./skillToSkillRelation.service";

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

These tests do not follow the convention we have refer to the testing guidelines documentation

The tests are expected to follow the Gherkin conventions when commenting in our tests.

modelId: string,
requiringSkillId: string,
requiredSkillId: string,
relationType: string

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Instead of the string, use enum SkillToSkillRelationType

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ohhh... my bad i though i fixed it as well i will check it

relationType: string
): Promise<ISkill & { relationType: SkillToSkillRelationType }> {
// 1. Validate relationType
if (relationType !== SkillToSkillRelationType.ESSENTIAL && relationType !== SkillToSkillRelationType.OPTIONAL) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is already tested via the handler.

We don't want to test it again (kind of waste of resources 😂, a joke).

It is a double work

}

// 2. Fetch the requiring skill
const requiringSkill = await this.skillRepository.findById(requiringSkillId);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This can fail, it should be trapped in a try-catch, so that the service is able to throw service errors

const createdRelations = await this.skillToSkillRelationRepository.createMany(modelId, [newRelationSpec]);

if (createdRelations.length === 0) {
throw new SkillToSkillRelationValidationError(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is not true.

If the createdRelations.length == 0, it does not mean that the code was incosistent only.

It can also mean that there were mongoose model construction errors.

Check the repository for more information.

Ideally the CODE INCOSISTENT is a business rule, it should belong to the service

Comment thread backend/src/esco/occupationToSkillRelation/occupationToSkillRelation.service.ts Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants