Skip to content

Commit

Permalink
🐛 fix parsing for some stupid course
Browse files Browse the repository at this point in the history
  • Loading branch information
H2Sxxa committed Feb 11, 2025
1 parent c5e5992 commit 16962e2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/extension/calendar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,14 +338,20 @@ pub fn parse_week_matrix(row_matrix: Vec<Vec<RawCourse>>) -> TorErr<Vec<ParsedCo
.map(|e| e.trim().to_string())
.collect();
let name = chucks[0].clone();
let place = chucks[1].clone();
let mut place = chucks[1].clone();
let oe: String;
let week: String;

// Name Place Time
if chucks.len() == 3 {
oe = String::new();
week = chucks[2].clone();
} else if chucks.len() == 2 {
// Can't promise to solve
// Only adapt for `CourseName Week`
place = String::new();
oe = String::new();
week = chucks[1].clone();
} else {
// Name Place OE Time
oe = chucks[2].clone();
Expand Down
4 changes: 3 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ mod test {
app::{AppVisitor, Application},
client::Client,
},
extension::calendar::CalendarParser,
extension::calendar::{parse_week_matrix, CalendarParser},
impls::{
apps::{sso::jwcas::JwcasApplication, wechat::jwqywx::JwqywxApplication},
client::DefaultClient,
Expand Down Expand Up @@ -76,7 +76,9 @@ mod test {
let client = DefaultClient::default();
let app = client.visit::<JwqywxApplication<_>>().await;
println!("{:?}", app.login().await.unwrap());
let matrix = app.get_classinfo_week_matrix().await.unwrap();
println!("{:?}", app.get_classinfo_week_matrix().await.unwrap());
parse_week_matrix(matrix).unwrap();
}
#[tokio::test]
async fn test_jwqywx() {
Expand Down

0 comments on commit 16962e2

Please sign in to comment.