Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(fiche SP): ne plus afficher en bas de page les liens "Voir aussi", "Pour en savoir plus" et "Service en ligne" #1508

Merged
merged 3 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
12 changes: 12 additions & 0 deletions shared/types/src/elastic/fiche-service-public.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { DocumentElasticWithSource } from "./common";
import {
FicheServicePublicDoc,
FicheTravailEmploiDoc,
Section,
} from "../hasura";
import { SOURCES } from "@socialgouv/cdtn-utils";

export type ElasticFicheServicePublic = DocumentElasticWithSource<
FicheServicePublicDoc,
typeof SOURCES.SHEET_SP
>;
28 changes: 20 additions & 8 deletions targets/ingester/src/transform/fichesServicePublic/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,30 @@ function getText(element?: RawJson): string {
return "";
}

const elementToNotDisplay = [
"OuSAdresser",
"ServiceEnLigne",
"QuestionReponse",
"VoirAussi",
"PourEnSavoirPlus",
"Definition",
"Abreviation",
];

const filterOutElementToNotDisplay = (publication: RawJson) =>
publication.children.filter(
(child) => !elementToNotDisplay.includes(child.name),
);

export function format(
fiche: RawJson,
resolveCdtReference: ReferenceResolver,
agreements: ShortAgreement[]
agreements: ShortAgreement[],
): Omit<FicheServicePublic, "is_searchable" | "slug"> {
const publication = fiche.children[0];
const { ID: id } = publication.attributes;

// We filter out the elements we will never use nor display
publication.children = publication.children.filter(
(child) => child.name !== "OuSAdresser" && child.name !== "ServiceEnLigne"
);
publication.children = filterOutElementToNotDisplay(publication);

const title = getText(getChild(publication, "dc:title"));
const description = getText(getChild(publication, "dc:description"));
Expand All @@ -54,7 +66,7 @@ export function format(
const date = `${day}/${month}/${year}`;

const audience = getText(
getChild(publication, "Audience")
getChild(publication, "Audience"),
).toLowerCase() as Audience;

const url = generateFichesSpRef(audience, id);
Expand All @@ -65,13 +77,13 @@ export function format(
const text = intro + " " + texte + " " + listeSituations;

const references = publication.children.filter(
(el) => el.name === "Reference"
(el) => el.name === "Reference",
);

const referencedTexts = parseReferences(
references,
resolveCdtReference,
agreements
agreements,
);

return {
Expand Down
Loading