-
Notifications
You must be signed in to change notification settings - Fork 3
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
Conversation
835c55e
to
b38a708
Compare
const INDEXED_AGREEMENTS = | ||
/** @type {KaliData.IndexedAgreement[]} */ | ||
(require("../../data/index.json")); | ||
var agreementsCache = undefined; |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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.
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. |
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) |
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 :) |
du coup je fais une PR pour une GH action qui check ce fichier tous les soirs et commit si changement ?
|
Oui c'est ça @revolunet :) |
On le met dans l'action GH fetch ? Comme ça c'est dans le processus de mise à jour du dépôt. |
closes SocialGouv/cdtn-admin#1255