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);
|
||||
}
|
||||
}
|
||||
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_vec = Vec::new();
|
||||
let info_list = xml
|
||||
.as_object()
|
||||
.unwrap()
|
||||
@ -135,7 +136,7 @@ pub async fn get_today_timetable(_conn: DbConn) -> Vec<Timetable> {
|
||||
.get("ZiZeile")
|
||||
.unwrap_or(&empty_list)
|
||||
.as_array()
|
||||
.unwrap();
|
||||
.unwrap_or(&empty_vec);
|
||||
let mut info = String::new();
|
||||
for item in info_list {
|
||||
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);
|
||||
}
|
||||
}
|
||||
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_vec = Vec::new();
|
||||
let info_list = xml
|
||||
.as_object()
|
||||
.unwrap()
|
||||
@ -227,7 +229,7 @@ pub async fn get_timetable(_conn: DbConn) -> Vec<Timetable> {
|
||||
.get("ZiZeile")
|
||||
.unwrap_or(&empty_list)
|
||||
.as_array()
|
||||
.unwrap();
|
||||
.unwrap_or(&empty_vec);
|
||||
let mut info = String::new();
|
||||
for item in info_list {
|
||||
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 classes = get_today_timetable_xml_data().await;
|
||||
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_vec = Vec::new();
|
||||
let info_list = xml
|
||||
.as_object()
|
||||
.unwrap()
|
||||
@ -294,7 +297,7 @@ pub async fn get_today_class_timetable(_conn: DbConn, class: String) -> Timetabl
|
||||
.get("ZiZeile")
|
||||
.unwrap_or(&empty_list)
|
||||
.as_array()
|
||||
.unwrap();
|
||||
.unwrap_or(&empty_vec);
|
||||
let mut info = String::new();
|
||||
for item in info_list {
|
||||
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 classes = get_timetable_xml_data().await;
|
||||
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_vec = Vec::new();
|
||||
let info_list = xml
|
||||
.as_object()
|
||||
.unwrap()
|
||||
@ -361,7 +365,7 @@ pub async fn get_class_timetable(_conn: DbConn, class: String) -> TimetableData
|
||||
.get("ZiZeile")
|
||||
.unwrap_or(&empty_list)
|
||||
.as_array()
|
||||
.unwrap();
|
||||
.unwrap_or(&empty_vec);
|
||||
let mut info = String::new();
|
||||
for item in info_list {
|
||||
info.push_str(item.as_str().unwrap_or("\r\n"));
|
||||
|
Reference in New Issue
Block a user