From aa4ea8cc4ea0650a09683867afd8b1783380e2e3 Mon Sep 17 00:00:00 2001 From: Matthieu Bessat Date: Sun, 21 Jan 2024 23:35:08 +0100 Subject: [PATCH] feat: sort answer by date, olders firsts --- TODO.md | 4 ++++ src/helloasso.rs | 2 ++ src/sync_csv.rs | 2 ++ 3 files changed, 8 insertions(+) diff --git a/TODO.md b/TODO.md index 89ce09e..9bd384b 100644 --- a/TODO.md +++ b/TODO.md @@ -58,3 +58,7 @@ curl -u $PAHEKO_CLIENT_ID:$PAHEKO_CLIENT_SECRET http://localhost:8082/api/sql -d - handle additional donation amount +## 2024-01-21 + +- to sort members by date, process older answers first + diff --git a/src/helloasso.rs b/src/helloasso.rs index b2d9121..92ed7d0 100644 --- a/src/helloasso.rs +++ b/src/helloasso.rs @@ -355,6 +355,8 @@ impl Organization { for entry in data { answers.push(serde_json::from_value(entry).context("Cannot parse FormAnswer")?) } + // sort by date, most older first + answers.sort_by(|a, b| a.order.inception_time.cmp(&b.order.inception_time)); Ok(answers) } } diff --git a/src/sync_csv.rs b/src/sync_csv.rs index ffbde7a..de550f7 100644 --- a/src/sync_csv.rs +++ b/src/sync_csv.rs @@ -139,6 +139,8 @@ pub async fn sync_csv( generalized_answers.push(generalized_answer); } + // sort by date, most older first + generalized_answers.sort_by(|a, b| a.inception_time.cmp(&b.inception_time)); eprintln!("Generated GeneralizedAnswers"); sync_paheko( paheko_client,