From 35adfc76b78e98661645fe21b968148fe8067687 Mon Sep 17 00:00:00 2001 From: Stadnik Andrii Date: Fri, 24 May 2024 20:26:13 +0300 Subject: [PATCH] Download multiple languages --- core/src/model/mod.rs | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/core/src/model/mod.rs b/core/src/model/mod.rs index 0c12ed70..81b0437a 100644 --- a/core/src/model/mod.rs +++ b/core/src/model/mod.rs @@ -63,13 +63,16 @@ pub fn get_data_from_file(filename: &str) -> anyhow::Result { pub async fn get_data_from_web() -> anyhow::Result { let sheet_id = env!("SHEET_ID"); - assert!(Lang::iter().count() == 1, "Only one language is supported"); - let lang = Lang::iter().next().unwrap(); - let sheet_name = lang.name(); - let url = format!( - "https://docs.google.com/spreadsheets/d/{}/gviz/tq?tqx=out:csv&sheet={}", - sheet_id, sheet_name - ); - let rdr = Reader::from_reader(reqwest::get(url).await?.bytes().await?.reader()); - Ok([(lang, get_finite_state(rdr, lang)?)].into()) + // assert!(Lang::iter().count() == 1, "Only one language is supported"); + let mut ret = MultilangFs::default(); + for lang in Lang::iter() { + let url = format!( + "https://docs.google.com/spreadsheets/d/{}/gviz/tq?tqx=out:csv&sheet={}", + sheet_id, + lang.name() + ); + let rdr = Reader::from_reader(reqwest::get(url).await?.bytes().await?.reader()); + ret.insert(lang, get_finite_state(rdr, lang)?); + } + Ok(ret) }