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

Récupération des avis depuis la db #5

Open
wants to merge 1 commit into
base: rat-component
Choose a base branch
from

Conversation

cyprienraf
Copy link
Collaborator

Ajout d'une fonction dans le back permettant l’accès à la liste des avis du restaurant voulu

Copy link

vercel bot commented May 13, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
keskon-mange-ce-midi ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 14, 2024 0:39am

@cyprienraf cyprienraf requested a review from Loiklak May 13, 2024 13:47
@cyprienraf cyprienraf changed the base branch from main to rat-component May 13, 2024 14:52
Copy link
Collaborator

@thomasperrein thomasperrein left a comment

Choose a reason for hiding this comment

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

Pas de magic string, ni de magic number, ça suit l'idiome DRY, le naming est bon, quelques petites remarques en commentaire
J'aurais aimé avoir un screen du résultat dans la PRR pour voir que ça marche vraiment :p

): header is GoogleSheetsExpectedColumnNames[] {
const expectedHeader = Object.keys(sheetsColumnsToTechnicalName);
return header.every((col) => expectedHeader.includes(col));
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

La fonction existe déjà dans ce qu'avais fait corentin il me semble

return avisStringKeys.includes(key);
}

const arrayToAvisInfos = (data: string[][]): AvisInfos[] => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Pourquoi mélanger du français et de l'anglais ? On pouvait pas traduire aussi "Avis" en anglais avec "Review" pour rester cohérent ?

Copy link
Owner

Choose a reason for hiding this comment

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

Je suis d'accord

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ça tombe bien moi aussi !

keyof typeof sheetsColumnsToTechnicalName;

// Correct header type guard
function isCorrectHeader(
Copy link
Owner

Choose a reason for hiding this comment

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

Le naming est trop vague ici, c'est quoi un header correct ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

J'ai remplacé par IsReviewInfoHeader :)

Comment on lines 7 to 11
enum Evaluation {
BAD_EVALUATION,
MEDIUM_EVALUATION,
GOOD_EVALUATION,
}
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
enum Evaluation {
BAD_EVALUATION,
MEDIUM_EVALUATION,
GOOD_EVALUATION,
}
enum Evaluation {
BAD_EVALUATION = "BAD_EVALUATION",
MEDIUM_EVALUATION,
GOOD_EVALUATION,
}

Pareil pour les autres

return avisStringKeys.includes(key);
}

const arrayToAvisInfos = (data: string[][]): AvisInfos[] => {
Copy link
Owner

Choose a reason for hiding this comment

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

Je suis d'accord

const AvisTable = await reponse.json();
const data = AvisTable.values;

const AvisInfoTable = arrayToAvisInfos(data);
Copy link
Owner

Choose a reason for hiding this comment

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

Utiliser le bon casing ;)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ok, c'est réparé !

{} as Record<TGroupByIndex, TInput[]>
);

const getAllAvisByAllRestaurant = async () => {
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
const getAllAvisByAllRestaurant = async () => {
const getRestaurantNameToAvis = async () => {

return allAvisByAllRestaurant;
};

export const getAllAvisbyRestaurant = async (restaurantName: string) => {
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
export const getAllAvisbyRestaurant = async (restaurantName: string) => {
export const getAvisForRestaurant = async (restaurantName: string) => {

@@ -0,0 +1,53 @@
export interface AvisInfos {
Copy link
Owner

Choose a reason for hiding this comment

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

Plutôt séparer en 3 fichiers pour bien compartimenter :

  • Un commun avec les types
  • 2 pour les type guards

Comment on lines 2 to 4
documentID: string | undefined,
valuesRange: string | undefined,
googleSheetsAPIKey: string | undefined
Copy link
Owner

Choose a reason for hiding this comment

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

On veut pas que ça soit undefined là, sinon on peut pas faire le call

Copy link
Owner

Choose a reason for hiding this comment

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

Gérer le cas undefined le plus proche possible de la source

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants