fixed error when no additional info
This commit is contained in:
parent
7bd8063a42
commit
2e3e856d72
@ -123,8 +123,9 @@ pub async fn get_today_timetable(_conn: DbConn) -> Vec<Timetable> {
|
|||||||
dbg!("Failed: {:?}", &i);
|
dbg!("Failed: {:?}", &i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let empty_list = serde_json::Value::Array(Vec::new());
|
let empty_list = serde_json::Value::Array(vec![]);
|
||||||
let empty_obj = serde_json::Value::Object(Map::new());
|
let empty_obj = serde_json::Value::Object(Map::new());
|
||||||
|
let empty_vec = Vec::new();
|
||||||
let info_list = xml
|
let info_list = xml
|
||||||
.as_object()
|
.as_object()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
@ -135,7 +136,7 @@ pub async fn get_today_timetable(_conn: DbConn) -> Vec<Timetable> {
|
|||||||
.get("ZiZeile")
|
.get("ZiZeile")
|
||||||
.unwrap_or(&empty_list)
|
.unwrap_or(&empty_list)
|
||||||
.as_array()
|
.as_array()
|
||||||
.unwrap();
|
.unwrap_or(&empty_vec);
|
||||||
let mut info = String::new();
|
let mut info = String::new();
|
||||||
for item in info_list {
|
for item in info_list {
|
||||||
info.push_str(item.as_str().unwrap_or("\r\n"));
|
info.push_str(item.as_str().unwrap_or("\r\n"));
|
||||||
@ -215,8 +216,9 @@ pub async fn get_timetable(_conn: DbConn) -> Vec<Timetable> {
|
|||||||
dbg!("Failed: {:?}", &i);
|
dbg!("Failed: {:?}", &i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let empty_list = serde_json::Value::Array(Vec::new());
|
let empty_list = serde_json::Value::Array(vec![]);
|
||||||
let empty_obj = serde_json::Value::Object(Map::new());
|
let empty_obj = serde_json::Value::Object(Map::new());
|
||||||
|
let empty_vec = Vec::new();
|
||||||
let info_list = xml
|
let info_list = xml
|
||||||
.as_object()
|
.as_object()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
@ -227,7 +229,7 @@ pub async fn get_timetable(_conn: DbConn) -> Vec<Timetable> {
|
|||||||
.get("ZiZeile")
|
.get("ZiZeile")
|
||||||
.unwrap_or(&empty_list)
|
.unwrap_or(&empty_list)
|
||||||
.as_array()
|
.as_array()
|
||||||
.unwrap();
|
.unwrap_or(&empty_vec);
|
||||||
let mut info = String::new();
|
let mut info = String::new();
|
||||||
for item in info_list {
|
for item in info_list {
|
||||||
info.push_str(item.as_str().unwrap_or("\r\n"));
|
info.push_str(item.as_str().unwrap_or("\r\n"));
|
||||||
@ -282,8 +284,9 @@ pub async fn get_today_class_timetable(_conn: DbConn, class: String) -> Timetabl
|
|||||||
let xml = get_today_timetable_xml().await;
|
let xml = get_today_timetable_xml().await;
|
||||||
let classes = get_today_timetable_xml_data().await;
|
let classes = get_today_timetable_xml_data().await;
|
||||||
let courses: Vec<rocket::serde::json::Value> = Vec::new();
|
let courses: Vec<rocket::serde::json::Value> = Vec::new();
|
||||||
let empty_list = serde_json::Value::Array(Vec::new());
|
let empty_list = serde_json::Value::Array(vec![]);
|
||||||
let empty_obj = serde_json::Value::Object(Map::new());
|
let empty_obj = serde_json::Value::Object(Map::new());
|
||||||
|
let empty_vec = Vec::new();
|
||||||
let info_list = xml
|
let info_list = xml
|
||||||
.as_object()
|
.as_object()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
@ -294,7 +297,7 @@ pub async fn get_today_class_timetable(_conn: DbConn, class: String) -> Timetabl
|
|||||||
.get("ZiZeile")
|
.get("ZiZeile")
|
||||||
.unwrap_or(&empty_list)
|
.unwrap_or(&empty_list)
|
||||||
.as_array()
|
.as_array()
|
||||||
.unwrap();
|
.unwrap_or(&empty_vec);
|
||||||
let mut info = String::new();
|
let mut info = String::new();
|
||||||
for item in info_list {
|
for item in info_list {
|
||||||
info.push_str(item.as_str().unwrap_or("\r\n"));
|
info.push_str(item.as_str().unwrap_or("\r\n"));
|
||||||
@ -349,8 +352,9 @@ pub async fn get_class_timetable(_conn: DbConn, class: String) -> TimetableData
|
|||||||
let xml = get_timetable_xml().await;
|
let xml = get_timetable_xml().await;
|
||||||
let classes = get_timetable_xml_data().await;
|
let classes = get_timetable_xml_data().await;
|
||||||
let courses: Vec<rocket::serde::json::Value> = Vec::new();
|
let courses: Vec<rocket::serde::json::Value> = Vec::new();
|
||||||
let empty_list = serde_json::Value::Array(Vec::new());
|
let empty_list = serde_json::Value::Array(vec![]);
|
||||||
let empty_obj = serde_json::Value::Object(Map::new());
|
let empty_obj = serde_json::Value::Object(Map::new());
|
||||||
|
let empty_vec = Vec::new();
|
||||||
let info_list = xml
|
let info_list = xml
|
||||||
.as_object()
|
.as_object()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
@ -361,7 +365,7 @@ pub async fn get_class_timetable(_conn: DbConn, class: String) -> TimetableData
|
|||||||
.get("ZiZeile")
|
.get("ZiZeile")
|
||||||
.unwrap_or(&empty_list)
|
.unwrap_or(&empty_list)
|
||||||
.as_array()
|
.as_array()
|
||||||
.unwrap();
|
.unwrap_or(&empty_vec);
|
||||||
let mut info = String::new();
|
let mut info = String::new();
|
||||||
for item in info_list {
|
for item in info_list {
|
||||||
info.push_str(item.as_str().unwrap_or("\r\n"));
|
info.push_str(item.as_str().unwrap_or("\r\n"));
|
||||||
|
Reference in New Issue
Block a user