Skip to content

Commit

Permalink
feat(stages): ajout de la transformation hellowork
Browse files Browse the repository at this point in the history
  • Loading branch information
juliebrunetto83 committed Sep 29, 2023
1 parent a43f56f commit e47ace0
Show file tree
Hide file tree
Showing 9 changed files with 951 additions and 1 deletion.
22 changes: 21 additions & 1 deletion apps/stages/src/transformation/application-service/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import { AssainisseurDeTexte } from "@shared/src/domain/service/assainisseur-de-
import { DateService } from "@shared/src/domain/service/date.service";
import { Pays } from "@shared/src/domain/service/pays";

import {
TransformerFluxHellowork,
} from "@stages/src/transformation/application-service/transformer-flux-hellowork.usecase";
import {
TransformerFluxJobteaser,
} from "@stages/src/transformation/application-service/transformer-flux-jobteaser.usecase";
Expand All @@ -14,6 +17,9 @@ import {
import {
TransformerFluxStagefrDecompresse,
} from "@stages/src/transformation/application-service/transformer-flux-stagefr-decompresse.usecase";
import {
Convertir as ConvertirHellowork,
} from "@stages/src/transformation/domain/service/hellowork/convertir.domain-service";
import {
Convertir as ConvertirJobteaser,
} from "@stages/src/transformation/domain/service/jobteaser/convertir.domain-service";
Expand All @@ -29,6 +35,13 @@ import { Gateways } from "@stages/src/transformation/infrastructure/gateway";
@Module({
imports: [Gateways, Shared],
providers: [
{
provide: ConvertirHellowork,
inject: [DateService, "Pays"],
useFactory: (dateService: DateService, pays: Pays): ConvertirHellowork => {
return new ConvertirHellowork(dateService, pays);
},
},
{
provide: ConvertirJobteaser,
inject: [DateService, "AssainisseurDeTexte", "Pays"],
Expand Down Expand Up @@ -57,6 +70,13 @@ import { Gateways } from "@stages/src/transformation/infrastructure/gateway";
return new TransformerFluxJobteaser(offreDeStageRepository, convertirOffreDeStage);
},
},
{
provide: TransformerFluxHellowork,
inject: ["OffreDeStageRepository", ConvertirHellowork],
useFactory: (offreDeStageRepository: OffreDeStageRepository, convertirOffreDeStage: ConvertirHellowork): TransformerFluxHellowork => {
return new TransformerFluxHellowork(offreDeStageRepository, convertirOffreDeStage);
},
},
{
provide: TransformerFluxStagefrCompresse,
inject: ["OffreDeStageRepository", ConvertirStagefrCompresse],
Expand All @@ -72,7 +92,7 @@ import { Gateways } from "@stages/src/transformation/infrastructure/gateway";
},
},
],
exports: [TransformerFluxJobteaser, TransformerFluxStagefrCompresse, TransformerFluxStagefrDecompresse],
exports: [TransformerFluxHellowork, TransformerFluxJobteaser, TransformerFluxStagefrCompresse, TransformerFluxStagefrDecompresse],
})
export class Usecases {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { Usecase } from "@shared/src/application-service/usecase";

import { UnJeune1Solution } from "@stages/src/transformation/domain/model/1jeune1solution";
import { FluxTransformation } from "@stages/src/transformation/domain/model/flux";
import { Hellowork } from "@stages/src/transformation/domain/model/hellowork";
import { Convertir } from "@stages/src/transformation/domain/service/hellowork/convertir.domain-service";
import { OffreDeStageRepository } from "@stages/src/transformation/domain/service/offre-de-stage.repository";

export class TransformerFluxHellowork implements Usecase {
constructor(
private readonly offreDeStageRepository: OffreDeStageRepository,
private readonly convertirOffreDeStage: Convertir,
) {
}

public async executer(flux: FluxTransformation): Promise<void> {
const contenuDuFlux = await this.offreDeStageRepository.recuperer<Hellowork.Contenu>(flux);

const contenuTransforme: Array<UnJeune1Solution.OffreDeStage>
= contenuDuFlux.source.job.map((job: Hellowork.OffreDeStage) => this.convertirOffreDeStage.depuisHellowork(job));

await this.offreDeStageRepository.sauvegarder(contenuTransforme, flux);
}
}
63 changes: 63 additions & 0 deletions apps/stages/src/transformation/domain/model/hellowork/domaine.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
export enum Domaine {
MARKETING = "Marketing",
INFORMATIQUE = "Informatique",
RESSOURCES_HUMAINES = "Ressources_Humaines",
COMMERCE = "Commerce",
NULL = "NULL",
COMMUNICATION = "Communication",
JURIDIQUE = "Juridique",
FINANCE = "Finance",
BTP = "Btp",
LOGISTIQUE = "Logistique",
INGENIERIE = "Ingenierie",
SECRETARIAT = "Secretariat",
QUALITE = "Qualite",
AUDIT = "Audit",
GESTION = "Gestion",
PRODUCTION = "Production",
RECHERCHE = "Recherche",
VENTE = "Vente",
ACHAT = "Achat",
COMPTABILITE = "Comptabilite",
SANTE = "Sante",
IMMOBILIER = "Immobilier",
INDUSTRIE = "Industrie",
GRAPHISME = "Graphisme",
DISTRIBUTION = "Distribution",
ADMINISTRATIF = "Administratif",
SAV = "Sav",
SECURITE = "Securite",
ENVIRONNEMENT = "Environnement",
DIRECTION = "Direction",
BANQUE = "Banque",
FORMATION = "Formation",
AUTOMOBILE = "Automobile",
EDITION = "Edition",
RESTAURATION = "Restauration",
TELECOM = "Telecom",
PUB = "Pub",
ELECTRONIQUE = "Electronique",
HOTELLERIE = "Hotellerie",
SERVICE_PUBLIC = "Service_Public",
ARCHITECTURE = "Architecture",
HOSPITALIER = "Hospitalier",
CHIMIE = "Chimie",
TRANSPORT = "Transport",
TOURISME = "Tourisme",
SERVICE = "Service",
AGRICOLE = "Agricole",
AUDIOVISUEL = "Audiovisuel",
NETTOYAGE = "Nettoyage",
AGROALIMENTAIRE = "Agroalimentaire",
SOCIAL = "Social",
BEAUTE = "Beaute",
ARTISANAT = "Artisanat",
CULTURE = "Culture",
ENSEIGNEMENT = "Enseignement",
BIOTECHNOLOGIE = "Biotechnologie",
ASSURANCE = "Assurance",
AERONAUTIQUE = "Aeronautique",
NAUTISME = "Nautisme",
DEFENSE = "Defense",
FERROVIAIRE = "Ferroviaire"
}
35 changes: 35 additions & 0 deletions apps/stages/src/transformation/domain/model/hellowork/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { Domaine as _Domaine } from "@stages/src/transformation/domain/model/hellowork/domaine";

export namespace Hellowork {
export type Contenu ={
source: {
job: Array<OffreDeStage>
}
}

export import Domaine = _Domaine

export type OffreDeStage = {
id: string;
reference?: string
// TODO (BRUJ 29-09-2023): format de la date
date: string
title: string
link: string
compagny: string
logo?: string
publisher?: string
city?: string
postalcode?: string
inseecode?: string
country?: string
geoloc?: string
description?: string
jobtype?: string
function?: string
seodomain?: _Domaine
category?: string
education?: string
salary?: string
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
import { DateService } from "@shared/src/domain/service/date.service";
import { Pays } from "@shared/src/domain/service/pays";

import { UnJeune1Solution } from "@stages/src/transformation/domain/model/1jeune1solution";
import { Hellowork } from "@stages/src/transformation/domain/model/hellowork";

export class Convertir {
private readonly correspondanceDomaines: Map<Hellowork.Domaine, UnJeune1Solution.Domaine>;

constructor(
private readonly dateService: DateService,
private readonly pays: Pays,
) {
this.correspondanceDomaines = new Map();
this.correspondanceDomaines.set(Hellowork.Domaine.MARKETING, UnJeune1Solution.Domaine.MARKETING);
this.correspondanceDomaines.set(Hellowork.Domaine.INFORMATIQUE, UnJeune1Solution.Domaine.INFORMATIQUE);
this.correspondanceDomaines.set(Hellowork.Domaine.RESSOURCES_HUMAINES, UnJeune1Solution.Domaine.RH);
this.correspondanceDomaines.set(Hellowork.Domaine.COMMERCE, UnJeune1Solution.Domaine.COMMERCE);
this.correspondanceDomaines.set(Hellowork.Domaine.NULL, UnJeune1Solution.Domaine.NON_APPLICABLE);
this.correspondanceDomaines.set(Hellowork.Domaine.COMMUNICATION, UnJeune1Solution.Domaine.COMMUNICATION);
this.correspondanceDomaines.set(Hellowork.Domaine.JURIDIQUE, UnJeune1Solution.Domaine.JURIDIQUE);
this.correspondanceDomaines.set(Hellowork.Domaine.FINANCE, UnJeune1Solution.Domaine.FISCALITE_FINANCE_ASSURANCE);
this.correspondanceDomaines.set(Hellowork.Domaine.IMMOBILIER, UnJeune1Solution.Domaine.ARCHITECTURE_URBANISME_IMMOBILIER);
this.correspondanceDomaines.set(Hellowork.Domaine.LOGISTIQUE, UnJeune1Solution.Domaine.LOGISTIQUE);
this.correspondanceDomaines.set(Hellowork.Domaine.INGENIERIE, UnJeune1Solution.Domaine.CONCEPTION_GENIE_CIVIL_INDUSTRIEL);
this.correspondanceDomaines.set(Hellowork.Domaine.SECRETARIAT, UnJeune1Solution.Domaine.DIRECTION_ENTREPRISE);
this.correspondanceDomaines.set(Hellowork.Domaine.QUALITE, UnJeune1Solution.Domaine.QUALITE_MAINTENANCE);
this.correspondanceDomaines.set(Hellowork.Domaine.AUDIT, UnJeune1Solution.Domaine.AUDIT);
this.correspondanceDomaines.set(Hellowork.Domaine.GESTION, UnJeune1Solution.Domaine.GESTION_PROJET);
this.correspondanceDomaines.set(Hellowork.Domaine.PRODUCTION, UnJeune1Solution.Domaine.PRODUCTION_FABRICATION_EXPLOITATION);
this.correspondanceDomaines.set(Hellowork.Domaine.RECHERCHE, UnJeune1Solution.Domaine.DATA);
this.correspondanceDomaines.set(Hellowork.Domaine.VENTE, UnJeune1Solution.Domaine.VENTES);
this.correspondanceDomaines.set(Hellowork.Domaine.ACHAT, UnJeune1Solution.Domaine.ACHATS);
this.correspondanceDomaines.set(Hellowork.Domaine.COMPTABILITE, UnJeune1Solution.Domaine.COMPTABILITE_CONTROLE_GESTION);
this.correspondanceDomaines.set(Hellowork.Domaine.SANTE, UnJeune1Solution.Domaine.SANTE);
this.correspondanceDomaines.set(Hellowork.Domaine.IMMOBILIER, UnJeune1Solution.Domaine.ARCHITECTURE_URBANISME_IMMOBILIER);
this.correspondanceDomaines.set(Hellowork.Domaine.INDUSTRIE, UnJeune1Solution.Domaine.PRODUCTION_FABRICATION_EXPLOITATION);
this.correspondanceDomaines.set(Hellowork.Domaine.GRAPHISME, UnJeune1Solution.Domaine.GRAPHISME);
this.correspondanceDomaines.set(Hellowork.Domaine.DISTRIBUTION, UnJeune1Solution.Domaine.ACHATS);
this.correspondanceDomaines.set(Hellowork.Domaine.ADMINISTRATIF, UnJeune1Solution.Domaine.SECTEUR_PUBLIC);
this.correspondanceDomaines.set(Hellowork.Domaine.SAV, UnJeune1Solution.Domaine.SUPPORT);
this.correspondanceDomaines.set(Hellowork.Domaine.SECURITE, UnJeune1Solution.Domaine.SANTE);
this.correspondanceDomaines.set(Hellowork.Domaine.ENVIRONNEMENT, UnJeune1Solution.Domaine.ENVIRONNEMENT);
this.correspondanceDomaines.set(Hellowork.Domaine.DIRECTION, UnJeune1Solution.Domaine.DIRECTION_ENTREPRISE);
this.correspondanceDomaines.set(Hellowork.Domaine.BANQUE, UnJeune1Solution.Domaine.FISCALITE_FINANCE_ASSURANCE);
this.correspondanceDomaines.set(Hellowork.Domaine.FORMATION, UnJeune1Solution.Domaine.RH);
this.correspondanceDomaines.set(Hellowork.Domaine.AUTOMOBILE, UnJeune1Solution.Domaine.PRODUCTION_FABRICATION_EXPLOITATION);
this.correspondanceDomaines.set(Hellowork.Domaine.EDITION, UnJeune1Solution.Domaine.NON_APPLICABLE);
this.correspondanceDomaines.set(Hellowork.Domaine.RESTAURATION, UnJeune1Solution.Domaine.SECTEUR_PUBLIC);
this.correspondanceDomaines.set(Hellowork.Domaine.TELECOM, UnJeune1Solution.Domaine.LOGISTIQUE);
this.correspondanceDomaines.set(Hellowork.Domaine.PUB, UnJeune1Solution.Domaine.HOTELLERIE);
this.correspondanceDomaines.set(Hellowork.Domaine.ELECTRONIQUE, UnJeune1Solution.Domaine.ENERGIE_MATERIAUX_MECANIQUE_ELECTRONIQUE);
this.correspondanceDomaines.set(Hellowork.Domaine.HOTELLERIE, UnJeune1Solution.Domaine.HOTELLERIE);
this.correspondanceDomaines.set(Hellowork.Domaine.SERVICE_PUBLIC, UnJeune1Solution.Domaine.SECTEUR_PUBLIC);
this.correspondanceDomaines.set(Hellowork.Domaine.ARCHITECTURE, UnJeune1Solution.Domaine.ARCHITECTURE_URBANISME_IMMOBILIER);
this.correspondanceDomaines.set(Hellowork.Domaine.HOSPITALIER, UnJeune1Solution.Domaine.SANTE);
this.correspondanceDomaines.set(Hellowork.Domaine.CHIMIE, UnJeune1Solution.Domaine.CHIMIE_BIOLOGIE_AGRONOMIE);
this.correspondanceDomaines.set(Hellowork.Domaine.TRANSPORT, UnJeune1Solution.Domaine.LOGISTIQUE);
this.correspondanceDomaines.set(Hellowork.Domaine.TOURISME, UnJeune1Solution.Domaine.HOTELLERIE);
this.correspondanceDomaines.set(Hellowork.Domaine.SERVICE, UnJeune1Solution.Domaine.NON_APPLICABLE);
this.correspondanceDomaines.set(Hellowork.Domaine.AGRICOLE, UnJeune1Solution.Domaine.AGRICULTURE);
this.correspondanceDomaines.set(Hellowork.Domaine.AUDIOVISUEL, UnJeune1Solution.Domaine.JOURNALISME_RP_MEDIAS);
this.correspondanceDomaines.set(Hellowork.Domaine.NETTOYAGE, UnJeune1Solution.Domaine.SANTE);
this.correspondanceDomaines.set(Hellowork.Domaine.AGROALIMENTAIRE, UnJeune1Solution.Domaine.AGRICULTURE);
this.correspondanceDomaines.set(Hellowork.Domaine.SOCIAL, UnJeune1Solution.Domaine.ACTIVITES_SOCIALES_CULTURELLES);
this.correspondanceDomaines.set(Hellowork.Domaine.BEAUTE, UnJeune1Solution.Domaine.SANTE);
this.correspondanceDomaines.set(Hellowork.Domaine.ARTISANAT, UnJeune1Solution.Domaine.PRODUCTION_FABRICATION_EXPLOITATION);
this.correspondanceDomaines.set(Hellowork.Domaine.CULTURE, UnJeune1Solution.Domaine.ACTIVITES_SOCIALES_CULTURELLES);
this.correspondanceDomaines.set(Hellowork.Domaine.ENSEIGNEMENT, UnJeune1Solution.Domaine.ENSEIGNEMENT);
this.correspondanceDomaines.set(Hellowork.Domaine.BIOTECHNOLOGIE, UnJeune1Solution.Domaine.CHIMIE_BIOLOGIE_AGRONOMIE);
this.correspondanceDomaines.set(Hellowork.Domaine.ASSURANCE, UnJeune1Solution.Domaine.FISCALITE_FINANCE_ASSURANCE);
this.correspondanceDomaines.set(Hellowork.Domaine.AERONAUTIQUE, UnJeune1Solution.Domaine.PRODUCTION_FABRICATION_EXPLOITATION);
this.correspondanceDomaines.set(Hellowork.Domaine.NAUTISME, UnJeune1Solution.Domaine.NON_APPLICABLE);
this.correspondanceDomaines.set(Hellowork.Domaine.DEFENSE, UnJeune1Solution.Domaine.SECTEUR_PUBLIC);
this.correspondanceDomaines.set(Hellowork.Domaine.FERROVIAIRE, UnJeune1Solution.Domaine.LOGISTIQUE);
}

public depuisHellowork(offreDeStage: Hellowork.OffreDeStage): UnJeune1Solution.OffreDeStage {
const maintenant = this.dateService.maintenant().toISOString();

return {
// TODO (BRUJ 29-09-2023): changer dateDeDebutMax/Min
dateDeDebutMax: "",
dateDeDebutMin: "",
description: offreDeStage.description,
domaines: [{ nom: this.traduireDomaine(offreDeStage.seodomain) }],
employeur: {
nom: offreDeStage.compagny,
logoUrl: offreDeStage.logo,
},
identifiantSource: offreDeStage.id,
localisation: this.recupererLaLocalisation(offreDeStage),
// TODO (BRUJ 29-09-2023): rajouter la rémunération en string
source: UnJeune1Solution.Source.HELLOWORK,
sourceCreatedAt: offreDeStage.date,
sourceUpdatedAt: offreDeStage.date,
sourcePublishedAt: maintenant,
titre: offreDeStage.title,
urlDeCandidature: offreDeStage.link,
};
}

private traduireDomaine(domaine: Hellowork.Domaine): UnJeune1Solution.Domaine {
const traductionDomaine = this.correspondanceDomaines.get(domaine);
return traductionDomaine || UnJeune1Solution.Domaine.NON_APPLICABLE;
}

private recupererLaLocalisation(offreDeStage: Hellowork.OffreDeStage): UnJeune1Solution.Localisation {
return {
ville: offreDeStage.city,
codePostal: offreDeStage.postalcode,
pays: this.pays.versFormatISOAlpha2(offreDeStage.country),
latitude: Number(offreDeStage.geoloc.split(",")[0]),
longitude: Number(offreDeStage.geoloc.split(",")[1]),
};
}
}
17 changes: 17 additions & 0 deletions apps/stages/src/transformation/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import { Module } from "@nestjs/common";
import { ConfigModule, ConfigService } from "@nestjs/config";

import { Usecases } from "@stages/src/transformation/application-service";
import {
TransformerFluxHellowork,
} from "@stages/src/transformation/application-service/transformer-flux-hellowork.usecase";
import {
TransformerFluxJobteaser,
} from "@stages/src/transformation/application-service/transformer-flux-jobteaser.usecase";
Expand All @@ -15,6 +18,9 @@ import {
Configuration,
ConfigurationFactory,
} from "@stages/src/transformation/infrastructure/configuration/configuration";
import {
TransformFlowHelloworkSubCommand,
} from "@stages/src/transformation/infrastructure/sub-command/transform-flow-hellowork.sub-command";
import {
TransformFlowJobteaserSubCommand,
} from "@stages/src/transformation/infrastructure/sub-command/transform-flow-jobteaser.sub-command";
Expand All @@ -34,6 +40,16 @@ import {
Usecases,
],
providers: [
{
provide: TransformFlowHelloworkSubCommand,
inject: [ConfigService, TransformerFluxHellowork],
useFactory: (
configurationService: ConfigService,
usecase: TransformerFluxHellowork
): TransformFlowHelloworkSubCommand => {
return new TransformFlowHelloworkSubCommand(usecase, configurationService.get<Configuration>("stagesTransformation"));
},
},
{
provide: TransformFlowJobteaserSubCommand,
inject: [ConfigService, TransformerFluxJobteaser],
Expand Down Expand Up @@ -66,6 +82,7 @@ import {
},
],
exports: [
TransformFlowHelloworkSubCommand,
TransformFlowJobteaserSubCommand,
TransformFlowStagefrCompressedSubCommand,
TransformFlowStagefrUncompressedSubCommand,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export type Configuration = {
DOMAINE: Domaine
FLOWS: Array<string>
JOBTEASER: TaskConfiguration
HELLOWORK: TaskConfiguration
LOGGER_LOG_LEVEL: LogLevel
MINIO: MinioConfiguration
NODE_ENV: Environment
Expand All @@ -50,10 +51,17 @@ export class ConfigurationFactory extends ConfigurationValidator {
CONTEXT: "transformation",
DOMAINE: "Stages",
FLOWS: [
getOrError("INTERNSHIPS_HELLOWORK_NAME"),
getOrError("INTERNSHIPS_JOBTEASER_NAME"),
getOrError("INTERNSHIPS_STAGEFR_COMPRESSED_NAME"),
getOrError("INTERNSHIPS_STAGEFR_UNCOMPRESSED_NAME"),
],
HELLOWORK: {
DIRECTORY_NAME: getOrError("INTERNSHIPS_HELLOWORK_DIRECTORY_NAME"),
NAME: getOrError("INTERNSHIPS_HELLOWORK_NAME"),
RAW_FILE_EXTENSION: getOrError("INTERNSHIPS_HELLOWORK_RAW_FILE_EXTENSION"),
TRANSFORMED_FILE_EXTENSION: getOrError("INTERNSHIPS_HELLOWORK_TRANSFORMED_FILE_EXTENSION"),
},
JOBTEASER: {
DIRECTORY_NAME: getOrError("INTERNSHIPS_JOBTEASER_DIRECTORY_NAME"),
NAME: getOrError("INTERNSHIPS_JOBTEASER_NAME"),
Expand Down
Loading

0 comments on commit e47ace0

Please sign in to comment.