From 1b023e6042d7a71c984658f790c60649503d7090 Mon Sep 17 00:00:00 2001 From: Matthieu Bessat Date: Mon, 8 Apr 2024 22:26:16 +0200 Subject: [PATCH] fix(csv): column name as english --- src/sync_csv.rs | 47 ++++++++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/src/sync_csv.rs b/src/sync_csv.rs index 6232771..a2d1866 100644 --- a/src/sync_csv.rs +++ b/src/sync_csv.rs @@ -37,48 +37,47 @@ pub async fn sync_csv( paheko_client: &paheko::AuthentifiedClient, config: &Config, _user_cache: &mut UserCache, - _dry_run: bool + dry_run: bool ) -> Result<()> { // raw row record directly from CSV #[derive(Debug, serde::Deserialize)] struct AnswerRecord { - #[serde(rename = "Date")] + // Ref BP + reference: String, + date: String, - #[serde(rename = "Email acheteur")] email: String, - #[serde(rename = "Prénom")] first_name: String, - #[serde(rename = "Nom")] last_name: String, - #[serde(rename = "Tarif")] + // Mode / Tarif "Individuel" "Couple" membership_mode: String, - #[serde(rename = "Cotisation (€)")] - subscription_amount: String, - #[serde(rename = "Don (€)")] - donation_amount: String, - - #[serde(rename = "CC 1 Prénom conjoint")] + // CC 1 Prénom conjoint linked_user_first_name: String, - #[serde(rename = "CC 2 ADRESSE")] + // CC 2 ADRESSE address: String, - #[serde(rename = "CC 3 CODE POSTAL")] + // CC 3 CODE POSTAL postal_code: String, - #[serde(rename = "CC 4 VILLE")] + // CC 4 VILLE city: String, - #[serde(rename = "CC 5 TÉLÉPHONE")] + // CC 5 TÉLÉPHONE phone: String, - #[serde(rename = "CC 7 PROFESSION")] + // CC 7 PROFESSION job: String, - #[serde(rename = "CC 8 CENTRE D'INTÉRÊTS / COMPÉTENCES")] + // CC 8 CENTRE D'INTÉRÊTS / COMPÉTENCES skills: String, - #[serde(rename = "CC 9 DATE DE NAISSANCE")] + // CC 9 DATE DE NAISSANCE birth_date: String, - #[serde(rename = "REF BP/")] - reference: String + // Cotisation (€) + subscription_amount: String, + // Don (€) + donation_amount: String, + + // Mode de paiement + payment_mode: String } let stdin = io::stdin(); @@ -142,6 +141,12 @@ pub async fn sync_csv( // sort by date, most older first generalized_answers.sort_by(|a, b| a.inception_time.cmp(&b.inception_time)); eprintln!("Generated GeneralizedAnswers"); + if dry_run { + dbg!(generalized_answers); + eprintln!("Stopping here, dry run"); + return Ok(()); + } + sync_paheko( paheko_client, config,