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: récupérer la liste des conventions collectives depuis un lien externe #300

Closed
wants to merge 1 commit into from

Conversation

m-maillot
Copy link
Contributor

@m-maillot m-maillot force-pushed the feat/retrieve-agreements branch from 835c55e to b38a708 Compare February 13, 2024 16:41
const INDEXED_AGREEMENTS =
/** @type {KaliData.IndexedAgreement[]} */
(require("../../data/index.json"));
var agreementsCache = undefined;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Gestion d'un cache simple pour éviter d'appeler l'API à chaque fois :)

const containsId = convention => typeof convention.id === "string";
async function getAgreements() {
if (!agreementsCache) {
const agreements = await fetch(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Je ne comprends pas l'erreur, le fetch est dispo dans node maintenant...


process.exit(-1);

async function main() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

J'ai du encapsuler les scripts dans des fonctions async.

async function getAgreements() {
if (!agreementsCache) {
const agreements = await fetch(
"https://cdtnadminprod.blob.core.windows.net/agreements/index.json",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Il faut d'abord faire tourner une mise en prod des données avec l'admin afin d'avoir ce fichier disponible.

@revolunet
Copy link
Member

du coup l'index ne sera plus dispo sur npm ?

@m-maillot
Copy link
Contributor Author

du coup l'index ne sera plus dispo sur npm ?

Non l'index n'est plus dispo @revolunet . Par contre, la méthode getAgreements de la librairie permet de récupérer les conventions collectives. Il faut donc passer par la méthode de la librairie pour récupérer les conventions collectives.

@revolunet
Copy link
Member

on pourrait pas ajouter une GH action qui récupère le fichier https://cdtnadminprod.blob.core.windows.net/agreements/index.json et l'intègre au paquet ? (je peux faire la PR)

@m-maillot
Copy link
Contributor Author

on pourrait pas ajouter une GH action qui récupère le fichier cdtnadminprod.blob.core.windows.net/agreements/index.json et l'intègre au paquet ? (je peux faire la PR)

On peut aussi, c'est même une bonne idée, ça casse pas le projet comme ça. Pour la PR, le fichier n'est pas encore disponible sur azure, du coup ça ne sera pas mergeable tant que le fichier n'est pas dispo. Par contre, tu peux utiliser cette URL pour tester : https://cdtnadmindev.blob.core.windows.net/cdtn/agreements.json :)

@m-maillot m-maillot marked this pull request as draft February 14, 2024 12:56
@revolunet
Copy link
Member

du coup je fais une PR pour une GH action qui check ce fichier tous les soirs et commit si changement ?

GET https://cdtnadmindev.blob.core.windows.net/cdtn/agreements.json > data/index.json ?

@m-maillot
Copy link
Contributor Author

Oui c'est ça @revolunet :)

@m-maillot
Copy link
Contributor Author

m-maillot commented Feb 14, 2024

On le met dans l'action GH fetch ? Comme ça c'est dans le processus de mise à jour du dépôt.

@m-maillot m-maillot closed this Apr 4, 2024
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.

[admin] Mettre à jour kali-data (pluger kali-data)
3 participants