Removed debugging code
Some checks failed
Rust / build_and_test (push) Has been cancelled

This commit is contained in:
Lukas Wölfer
2026-01-17 22:07:21 +01:00
parent 681cc0f59d
commit 0d88629b17
2 changed files with 16 additions and 19 deletions

View File

@@ -135,26 +135,16 @@ fn parse_stats(
rank: *rank,
});
Ok((primary_role, dominant_comp, non_dominant_comp))
// dbg!(chapters.collect::<Vec<_>>());
}
fn extract_tables(html: &str) -> Result<Vec<(String, Vec<Vec<String>>)>, ScoringParseError> {
dbg!(&html);
let document = Html::parse_document(html);
let card_selector = Selector::parse("div:has( > div.card-header)").unwrap();
document
.select(&card_selector)
.inspect(|v| {
dbg!(&v);
})
.map(parse_card)
.collect()
document.select(&card_selector).map(parse_card).collect()
}
fn parse_info(html: &str) -> Result<DanceInfo, ScoringParseError> {
let tables = extract_tables(html)?;
dbg!(&tables);
let details = &tables
.iter()
.find(|(v, _)| v.to_lowercase().contains("detail"))
@@ -178,11 +168,6 @@ fn parse_info(html: &str) -> Result<DanceInfo, ScoringParseError> {
})
}
#[test]
fn test_parse_table() {
dbg!(parse_info(include_str!("../../test_data/2026-01-07_robert.html")));
}
pub async fn fetch_wsdc_info_scoring_dance(id: u32) -> Result<DanceInfo, DanceInfoError> {
let client = ClientBuilder::new()
.user_agent(app_signature())
@@ -201,3 +186,16 @@ pub async fn fetch_wsdc_info_scoring_dance(id: u32) -> Result<DanceInfo, DanceIn
parse_info(response.text().await.unwrap().as_str()).map_err(DanceInfoError::HtmlParse)
}
#[cfg(test)]
mod tests {
#![allow(clippy::unwrap_used)]
use super::*;
#[test]
fn test_parse_table() {
let info = parse_info(include_str!("../../test_data/2025-10-02_polina.html")).unwrap();
assert_eq!(info.firstname, "Polina");
assert_eq!(info.lastname, "Gorushkina");
}
}

View File

@@ -2,8 +2,8 @@ use std::collections::HashMap;
use crate::{
app_signature,
dance_info::{CompState, DanceInfo, DanceRank, DanceRole},
fetching::{DanceInfoError, types::DanceInfoParser, scoringdance::{self, fetch_wsdc_info_scoring_dance}},
dance_info::DanceInfo,
fetching::{DanceInfoError, types::DanceInfoParser},
};
use reqwest::ClientBuilder;
@@ -16,7 +16,6 @@ pub async fn fetch_wsdc_info_wsdc(id: u32) -> Result<DanceInfo, DanceInfoError>
let mut params = HashMap::new();
let url = if cfg!(test) {
// "https://o5grQU3Y.free.beeceptor.com/lookup2020/find"
"http://localhost:8000"
} else {
"https://points.worldsdc.com/lookup2020/find"