fix(csv): column name as english

This commit is contained in:
Matthieu Bessat 2024-04-08 22:26:16 +02:00
parent 17bf5c0564
commit 1b023e6042

View file

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