removing not map-able LEIs
This commit is contained in:
@@ -83,19 +83,25 @@ pub async fn run_full_update(config: &Config, pool: &Arc<ChromeDriverPool>) -> a
|
||||
println!("{}", msg);
|
||||
logger::log_info(&msg).await;
|
||||
|
||||
// HashMap<Name, Vec<(ISIN, Ticker)>>
|
||||
let companies: HashMap<String, Vec<(String, String)>> = securities.0
|
||||
// HashMap<Name, HashMap<ISIN, Ticker>> - unique pairs only
|
||||
let companies: HashMap<String, HashMap<String, String>> = securities.0
|
||||
.iter()
|
||||
.fold(HashMap::new(), |mut acc, security| {
|
||||
let isin: Vec<String> = security.1.securities.values()
|
||||
.flat_map(|figi_info| figi_info.iter().map(|x| x.isin.clone()))
|
||||
.collect();
|
||||
let ticker: Vec<String> = security.1.securities.values()
|
||||
.flat_map(|figi_info| figi_info.iter().map(|x| x.ticker.clone()))
|
||||
.collect();
|
||||
acc.entry(security.1.name.clone())
|
||||
.or_insert_with(Vec::new)
|
||||
.push((isin.join(", "), ticker.join(", ")));
|
||||
let mut isin_ticker_pairs: HashMap<String, String> = HashMap::new();
|
||||
|
||||
// Collect all unique ISIN-Ticker pairs
|
||||
for figi_infos in security.1.securities.values() {
|
||||
for figi_info in figi_infos {
|
||||
if !figi_info.isin.is_empty() && !figi_info.ticker.is_empty() {
|
||||
isin_ticker_pairs.insert(figi_info.isin.clone(), figi_info.ticker.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Only add if there are pairs
|
||||
if !isin_ticker_pairs.is_empty() {
|
||||
acc.insert(security.1.name.clone(), isin_ticker_pairs);
|
||||
}
|
||||
acc
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user