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

feat(contenus): ajout d'une date #1458

Merged
merged 18 commits into from
Aug 22, 2024
Merged

feat(contenus): ajout d'une date #1458

merged 18 commits into from
Aug 22, 2024

Conversation

maxgfr
Copy link
Member

@maxgfr maxgfr commented Aug 19, 2024

@github-advanced-security
Copy link

This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation.

@maxgfr maxgfr marked this pull request as ready for review August 20, 2024 09:18
targets/frontend/src/pages/api/sitemap.ts Dismissed Show dismissed Hide dismissed
Copy link

sonarcloud bot commented Aug 21, 2024

Copy link

🎉 Deployment for commit 7780c80 :

Ingresses
Docker images
  • 📦 docker pull harbor.fabrique.social.gouv.fr/cdtn/cdtn-admin/export:sha-7780c80fedd36528585d2b1ce02c6a5d20ea4b66
  • 📦 docker pull harbor.fabrique.social.gouv.fr/cdtn/cdtn-admin/frontend:sha-7780c80fedd36528585d2b1ce02c6a5d20ea4b66
  • 📦 docker pull harbor.fabrique.social.gouv.fr/cdtn/cdtn-admin/hasura:sha-7780c80fedd36528585d2b1ce02c6a5d20ea4b66
Debug

@@ -8,6 +8,7 @@ export const getContributionAnswerById = gql`
description
content_type
updatedAt: updated_at
display_date
Copy link
Contributor

Choose a reason for hiding this comment

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

Optionnel mais ca serais pas plus sympa en camelcase ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Il serait même top de le mettre en camelCase directement dans Hasura :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Ouaip, c'est ce que j'ai fait côté model et information, mais globalement, côté contribution, on a tout en snake_case, donc ça risque de tout mélanger. Il faudrait limite faire un ticket pour refacto toutes les contributions en camelCase

Copy link
Member Author

Choose a reason for hiding this comment

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

Et cela bien évidemment, directement côté Hasura

-- Could not auto-generate a down migration.
-- Please write an appropriate down migration for the SQL below:
-- alter table "information"."informations" add column "display_date" date
-- null;
Copy link
Contributor

Choose a reason for hiding this comment

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

il faudrait mettre un down ici vu que le up alter le schéma

Copy link
Member Author

Choose a reason for hiding this comment

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

ouaip, mais bon, on l'a fait nul part.... puis après faut le tester, etc. est-ce worth it ?

-- Could not auto-generate a down migration.
-- Please write an appropriate down migration for the SQL below:
-- alter table "contribution"."answers" add column "display_date" date
-- null;
Copy link
Contributor

Choose a reason for hiding this comment

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

idem

-- Could not auto-generate a down migration.
-- Please write an appropriate down migration for the SQL below:
-- alter table "model"."models" add column "display_date" date
-- null;
Copy link
Contributor

Choose a reason for hiding this comment

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

idem


docker compose up --wait -d hasura elasticsearch
docker compose up --wait -d hasura elasticsearch minio createbuckets
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

render={({ field: { onChange, value } }) => (
<DatePicker
label={label}
value={formatDate(value)}
Copy link
Contributor

Choose a reason for hiding this comment

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

Ca ne semble pas trop être ce que la doc préconise pour le formatage https://mui.com/x/react-date-pickers/adapters-locale/
Est ce qu'il ya une raison de ne pas faire avec la método de date-fns ?

Copy link
Member Author

Choose a reason for hiding this comment

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

J'utilise bien date-fns comme dans la documentation pour formater mon input.

Le paramètre d'entrée est une date, or nous notre input issue de la DB est un string. D'où le fait que je sois obligé de le formater afin de lui renvoyer une date.

Pour la sortie, c'est un peu la même, car le DatePicker renvoie (du fait que je l'ai initialisé avec adapter) une valeur en string de type dd/MM/yyyy. Or de notre côté, ce qu'on veut sauvegarder côté DB est de format dateen yyyy-MM-dd. Afin d'éviter de le formater plus haut, je le fais directement dans le onChange du composant. Ca simplifie la gestion du formattage à un niveau local :)

@@ -8,6 +8,7 @@ export const getContributionAnswerById = gql`
description
content_type
updatedAt: updated_at
display_date
Copy link
Contributor

Choose a reason for hiding this comment

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

Il serait même top de le mettre en camelCase directement dans Hasura :)

@@ -237,7 +52,7 @@ export class DocumentsService {
cause: null,
});
}
document = await this.mapInformationToDocument(information, document);
document = await mapInformationToDocument(information, document);
Copy link
Contributor

Choose a reason for hiding this comment

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

Très bonne idée d'extraire ces méthodes du fichier. Ca devenait un trop gros fichier

}
const source = getRouteBySource(doc.source);
const priority =
source === SOURCES.EDITORIAL_CONTENT ||
source === "information" ||
Copy link
Contributor

Choose a reason for hiding this comment

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

Pourquoi ne pas utiliser les constantes SOURCES.INFORMATION et SOURCE.MODELES ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Car les valeurs sont différentes, en fait la valeur derrière la source est celle ci :
export type Document = { updated_at: string; slug: string; source: SourceRoute; document: any; };

SourceRoute sont les valeurs des keys SOURCES.INFORMATION, etc.

Donc les deux valeurs sont différentes, le type précédent était faux...

@maxgfr maxgfr merged commit 05a90c9 into master Aug 22, 2024
29 checks passed
@maxgfr maxgfr deleted the linked-ajout-date branch August 22, 2024 07:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants