Skip to content

Commit

Permalink
appelations to appellations
Browse files Browse the repository at this point in the history
  • Loading branch information
enguerranws committed Sep 17, 2024
1 parent f0e092c commit 2028791
Show file tree
Hide file tree
Showing 12 changed files with 33 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ describe("Route to get ImmersionSearchResultDto by siret and rome - /v2/offers/:
expect(response.status).toBe(200);
});

it("returns 404 if no offer can be found with such siret & appelation code", async () => {
it("returns 404 if no offer can be found with such siret & appellation code", async () => {
const siretNotInDB = "11000403200019";

const { status, body } =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ describe("Pg implementation of ConventionQueries", () => {
const conventionBuilderInitialMatching = new ConventionDtoBuilder()
.withAgencyId(agency.id)
.withSiret(matchingSiret)
.withImmersionAppelation({
.withImmersionAppellation({
appellationCode: matchingAppellation,
romeCode: "11111",
appellationLabel: "osef",
Expand Down Expand Up @@ -573,7 +573,7 @@ describe("Pg implementation of ConventionQueries", () => {

const conventionWithWrongAppellation = conventionBuilderInitialMatching
.withId("33333333-3333-4333-3333-333333333333")
.withImmersionAppelation({
.withImmersionAppellation({
appellationCode: "17010",
romeCode: "11111",
appellationLabel: "osef",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ describe("Broadcasts events to pole-emploi", () => {
const convention = new ConventionDtoBuilder()
.withId(immersionConventionId)
.withAgencyId(peAgency.id)
.withImmersionAppelation({
.withImmersionAppellation({
appellationCode: "11111",
appellationLabel: "some Appellation",
romeCode: "A1111",
Expand Down Expand Up @@ -263,7 +263,7 @@ describe("Broadcasts events to pole-emploi", () => {
const convention = new ConventionDtoBuilder()
.withId(immersionConventionId)
.withAgencyId(agencyWithRefersTo.id)
.withImmersionAppelation({
.withImmersionAppellation({
appellationCode: "11111",
appellationLabel: "some Appellation",
romeCode: "A1111",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export class InMemoryAppellationsGateway implements AppellationsGateway {
);
}

public setNextSearchAppelationsResult(nextResult: AppellationDto[]) {
public setNextSearchAppellationsResult(nextResult: AppellationDto[]) {
this.#nextResults = nextResult;
}

Expand Down
10 changes: 5 additions & 5 deletions back/src/domains/core/rome/adapters/PgRomeRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,20 @@ export class PgRomeRepository implements RomeRepository {
codes: AppellationCode[],
): Promise<AppellationAndRomeDto[]> {
return this.transaction
.selectFrom("public_appellations_data as appelations")
.selectFrom("public_appellations_data as appellations")
.innerJoin(
"public_romes_data as romes",
"appelations.code_rome",
"appellations.code_rome",
"romes.code_rome",
)
.where(
"appelations.ogr_appellation",
"appellations.ogr_appellation",
"in",
codes.map((code) => parseInt(code)),
)
.select([
"appelations.ogr_appellation",
"appelations.libelle_appellation_long",
"appellations.ogr_appellation",
"appellations.libelle_appellation_long",
"romes.libelle_rome",
"romes.code_rome",
])
Expand Down
8 changes: 4 additions & 4 deletions back/src/domains/core/rome/use-cases/AppellationSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class AppellationSearch extends TransactionalUseCase<
if (searchText.length < ROME_AND_APPELLATION_MIN_SEARCH_TEXT_LENGTH)
return [];
const appellations = fetchAppellationsFromNaturalLanguage
? await this.#naturalLanguageSearchAppelations(uow, searchText)
? await this.#naturalLanguageSearchAppellations(uow, searchText)
: await uow.romeRepository.searchAppellation(searchText);

const appellationsWithMatch: AppellationMatchDto[] = appellations.map(
Expand All @@ -67,15 +67,15 @@ export class AppellationSearch extends TransactionalUseCase<
return appellationsWithMatch;
}

async #naturalLanguageSearchAppelations(
async #naturalLanguageSearchAppellations(
uow: UnitOfWork,
searchText: string,
): Promise<AppellationAndRomeDto[]> {
const appelations =
const appellations =
await this.#appellationsGateway.searchAppellations(searchText);

return uow.romeRepository.getAppellationAndRomeDtosFromAppellationCodes(
appelations.map(({ appellationCode }) => appellationCode),
appellations.map(({ appellationCode }) => appellationCode),
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ describe("AppellationSearch", () => {
});
describe("with natural language search", () => {
it("returns the list of found matches with ranges", async () => {
appellationsGateway.setNextSearchAppelationsResult([
appellationsGateway.setNextSearchAppellationsResult([
{ appellationCode: "19364", appellationLabel: "Secrétaire" },
{
appellationCode: "19367",
Expand Down Expand Up @@ -136,7 +136,7 @@ describe("AppellationSearch", () => {
});

it("do not return results if missing on rome repo like ROME 4 results", async () => {
appellationsGateway.setNextSearchAppelationsResult([
appellationsGateway.setNextSearchAppellationsResult([
{ appellationCode: "19364", appellationLabel: "Secrétaire" },
{
appellationCode: "19367",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1071,7 +1071,7 @@ describe("PgEstablishmentAggregateRepository", () => {
});
});

describe("getOffersAsAppelationDtoForFormEstablishment", () => {
describe("getOffersAsAppellationDtoForFormEstablishment", () => {
beforeEach(async () => {
await pgEstablishmentAggregateRepository.insertEstablishmentAggregate(
establishmentWithOfferA1101_AtPosition,
Expand Down Expand Up @@ -1138,13 +1138,13 @@ describe("PgEstablishmentAggregateRepository", () => {
);
});

it("undefined when missing offer appelation code", async () => {
const missingAppelationCode = artisteCirqueOffer.appellationCode;
it("undefined when missing offer appellation code", async () => {
const missingAppellationCode = artisteCirqueOffer.appellationCode;

expectToEqual(
await pgEstablishmentAggregateRepository.getSearchImmersionResultDtoBySearchQuery(
establishmentWithOfferA1101_AtPosition.establishment.siret,
missingAppelationCode,
missingAppellationCode,
establishmentWithOfferA1101_AtPosition.establishment.locations[0]
.id,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -747,19 +747,19 @@ export class PgEstablishmentAggregateRepository
.where("rome_code", "in", offersToRemoveByRomeCode)
.execute();

const offersToRemoveByAppelationCode = offersToRemove
const offersToRemoveByAppellationCode = offersToRemove
.filter((offer) => !!offer.appellationCode)
.map((offer) => offer.appellationCode);

if (offersToRemoveByAppelationCode.length > 0)
if (offersToRemoveByAppellationCode.length > 0)
await this.transaction
.deleteFrom("immersion_offers")
.where("siret", "=", siret)
.where(
"appellation_code",
"in",
offersToRemoveByAppelationCode.map((appelationCode) =>
parseInt(appelationCode),
offersToRemoveByAppellationCode.map((appellationCode) =>
parseInt(appellationCode),
),
)
.execute();
Expand Down Expand Up @@ -958,7 +958,7 @@ const searchImmersionResultsQuery = (
"loc.id as loc_id",
"offer.rome_code as code_rome",
sql`JSON_AGG( JSON_BUILD_OBJECT( 'appellationCode', a.ogr_appellation::text, 'appellationLabel', a.libelle_appellation_long, 'score', offer.score ) ORDER BY a.ogr_appellation)`.as(
"appelations",
"appellations",
),
sql<number>`ROW_NUMBER() OVER (ORDER BY ${makeOrderByClauses(
sortedBy,
Expand Down Expand Up @@ -1025,7 +1025,7 @@ const searchImmersionResultsQuery = (
}
: {}),
voluntaryToImmersion: sql`TRUE`,
appellations: ref("r.appelations"),
appellations: ref("r.appellations"),
}),
).as("search_immersion_result"),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ describe("SendExchangeToRecipient", () => {
);
});

it("throws an error if appelation code does not exist", async () => {
it("throws an error if appellation code does not exist", async () => {
const discussion = new DiscussionBuilder()
.withAppellationCode("20567")
.withId(uuid())
Expand Down
2 changes: 1 addition & 1 deletion shared/src/convention/ConventionDtoBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ export class ConventionDtoBuilder implements Builder<ConventionDto> {
});
}

public withImmersionAppelation(
public withImmersionAppellation(
immersionAppellation: AppellationAndRomeDto,
): ConventionDtoBuilder {
return new ConventionDtoBuilder({
Expand Down
8 changes: 4 additions & 4 deletions shared/src/discussion/discussion.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,14 @@ export class DiscussionBuilder implements Builder<DiscussionDto> {
constructor(private readonly discussion: DiscussionDto = defaultDiscussion) {}

public buildRead(
appelation: AppellationAndRomeDto = cartographeAppellationAndRome,
appellation: AppellationAndRomeDto = cartographeAppellationAndRome,
): DiscussionReadDto {
const { appellationCode, ...rest } = this.discussion;
if (appelation.appellationCode !== appellationCode)
throw new Error("Appelation code mismatch");
if (appellation.appellationCode !== appellationCode)
throw new Error("Appellation code mismatch");
return {
...rest,
appellation: appelation,
appellation: appellation,
potentialBeneficiary: {
firstName: this.discussion.potentialBeneficiary.firstName,
lastName: this.discussion.potentialBeneficiary.lastName,
Expand Down

0 comments on commit 2028791

Please sign in to comment.