Skip to content

Commit

Permalink
ajout du script de recupération des urls de gestion pour les speakers
Browse files Browse the repository at this point in the history
  • Loading branch information
schassande committed Jan 12, 2025
1 parent 06a85a3 commit 32aac8e
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ src/astro_tmp_pages_*

voxxrin/talks-stats.csv
voxxrin/talks-stats.json
voxxrin/talks-url.csv
voxxrin/talks-url.json
voxxrin/feedback*.json
51 changes: 51 additions & 0 deletions voxxrin/talks-url.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
const fs = require('fs');
const createCsvWriter = require('csv-writer').createObjectCsvWriter;

// Fonction principale
async function convertJsonToCsv(inputFilePath, outputFilePath) {
try {
// Lire le fichier JSON
const jsonData = JSON.parse(fs.readFileSync(inputFilePath, 'utf8'));

// Vérification de la structure attendue
if (!jsonData || !Array.isArray(jsonData)) {
throw new Error("Le fichier JSON n'a pas le format attendu.");
}
// Créer un tableau contenant les données pour le CSV
const csvData = jsonData.filter(item => item.speakersFullNames.length > 0)
.map(item => ({
talkId: item.talkId,
talkTitle: item.speakersFullNames.join(', '),
registrationUrl: "https://"+item.registrationUrl
}));

// Configurer le writer CSV
const csvWriter = createCsvWriter({
path: outputFilePath,
header: [
{ id: 'talkId', title: 'talkId' },
{ id: 'talkTitle', title: 'talkTitle' },
{ id: 'registrationUrl', title: 'registrationUrl' }
]
});

// Écrire les données dans le fichier CSV
await csvWriter.writeRecords(csvData);

console.log(`Fichier CSV généré avec succès : ${outputFilePath}`);
} catch (error) {
console.error(`Erreur : ${error.message}`);
}
}

// Récupérer les paramètres de la ligne de commande
const args = process.argv.slice(2);

if (args.length < 1) {
console.error("Usage : node talks-url.cjs <chemin_du_fichier_JSON> [<chemin_du_fichier_CSV>]");
process.exit(1);
}

const inputFilePath = args[0];
const outputFilePath = args.length > 1 ? args[1] : 'talks-url.csv';
convertJsonToCsv(inputFilePath, outputFilePath);
30 changes: 30 additions & 0 deletions voxxrin/voxxrin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
###############################################################################
# Variables de configuration
###############################################################################
VOXXRIN_FRONT_END_BASE_URL=app.voxxr.in
VOXXRIN_BASE_URL=https://api.voxxr.in
VOXXRIN_EVENT_ID=snowcamp25

Expand Down Expand Up @@ -47,6 +48,29 @@ function getTalksStats() {
rm talks-stats.json
}

###############################################################################
# Recuperation des feedbacks d'un talk
###############################################################################
function getTalkFeedbacks() {
TALK_ID=$2
echo "Talk: $TALK_ID"
NOW=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
echo "Now: $NOW"
#{{baseUrl}}/api/events/{{eventId}}/talks/{{talkId}}/feedbacks?token={{secretToken}}&updatedSince={{updatedSinceISODatetime}}
curl --request GET --silent --url "${VOXXRIN_BASE_URL}/api/events/${VOXXRIN_EVENT_ID}/talks/${TALK_ID}/feedback?token=${VOXXRIN_TOKEN}&updatedSince=${NOW}" > feedback-${TALK_ID}.json
}

###############################################################################
# Recuperation de l'url de gestion des talks
###############################################################################
function getTalksUrl() {
#{{baseUrl}}/api/events/{{eventId}}/talksEditors?token={{secretToken}}&baseUrl={{voxxrinInstanceBaseUrl}}
curl --request GET --silent --url "${VOXXRIN_BASE_URL}/api/events/${VOXXRIN_EVENT_ID}/talksEditors?token=${VOXXRIN_TOKEN}&baseUrl=${VOXXRIN_FRONT_END_BASE_URL}" > talks-url.json
node talks-url.cjs talks-url.json
rm talks-url.json
}



###############################################################################
# Programme principal
Expand All @@ -58,6 +82,12 @@ case $1 in
"talks-stats")
getTalksStats $*
;;
"talks-url")
getTalksUrl $*
;;
"talk-feedbacks")
getTalkFeedbacks $*
;;
*)
usage
;;
Expand Down

0 comments on commit 32aac8e

Please sign in to comment.