v0.15-WORKINGV4

This commit is contained in:
2022-12-04 13:26:08 +05:30
parent c8fba74480
commit e6c091dde0
2 changed files with 30 additions and 23 deletions

View File

@@ -161,6 +161,7 @@ impl BookUI {
async fn set_descriptions(&mut self) {
if self.open_library_key.is_some() {
if !(self.open_library_key.as_ref().unwrap().is_empty()) {
let query = format!("https://openlibrary.org/{}.json", self.open_library_key.as_ref().unwrap().clone());
let res = reqwest::get(query).await.expect("Unable to request");
let resjson = res.json::<BookPageOL>().await.expect("Unable to return value");
@@ -175,6 +176,7 @@ async fn set_descriptions(&mut self) {
}
}
}
}
}
}
@@ -697,7 +699,7 @@ async fn create_book(
.await
.expect("could not create book");
for author_name in doc_sent.author_name.as_ref().unwrap().iter() {
for author_name in doc_sent.author_name.as_ref().unwrap_or(&vec!["".to_string()]).iter() {
let record : book_author::Model = book_author::Model{
id: 1,
book_id: (created_book.last_insert_id),
@@ -707,7 +709,7 @@ async fn create_book(
.await
.expect("could not create book");
}
for person in doc_sent.person.as_ref().unwrap().iter() {
for person in doc_sent.person.as_ref().unwrap_or(&vec!["".to_string()]).iter() {
let record : book_person::Model = book_person::Model{
id: 1,
book_id: (created_book.last_insert_id),
@@ -718,7 +720,7 @@ async fn create_book(
.expect("could not create book");
}
for place in doc_sent.place.as_ref().unwrap().iter() {
for place in doc_sent.place.as_ref().unwrap_or(&vec!["".to_string()]).iter() {
let record : book_place::Model = book_place::Model{
id: 1,
book_id: (created_book.last_insert_id),
@@ -729,7 +731,7 @@ async fn create_book(
.expect("could not create book");
}
for subject in doc_sent.subject.as_ref().unwrap().iter() {
for subject in doc_sent.subject.as_ref().unwrap_or(&vec!["".to_string()]).iter() {
let record : book_subject::Model = book_subject::Model{
id: 1,
book_id: (created_book.last_insert_id),
@@ -740,7 +742,7 @@ async fn create_book(
.expect("could not create book");
}
for time in doc_sent.time.as_ref().unwrap().iter() {
for time in doc_sent.time.as_ref().unwrap_or(&vec!["".to_string()]).iter() {
let record : book_time::Model = book_time::Model{
id: 1,
book_id: (created_book.last_insert_id),
@@ -751,7 +753,7 @@ async fn create_book(
.expect("could not create book");
}
for isbn in doc_sent.isbn.as_ref().unwrap().iter() {
for isbn in doc_sent.isbn.as_ref().unwrap_or(&vec!["".to_string()]).iter() {
let record : book_isbn::Model = book_isbn::Model{
id: 1,
book_id: (created_book.last_insert_id),
@@ -860,7 +862,7 @@ let book: book::Model = book::Model{
.await
.expect("could not delete book isbns while updating");
for author_name in doc_sent.author_name.as_ref().unwrap().iter() {
for author_name in doc_sent.author_name.as_ref().unwrap_or(&vec!["".to_string()]).iter() {
let record : book_author::Model = book_author::Model{
id: 1,
book_id: doc_sent.id,
@@ -870,7 +872,7 @@ let book: book::Model = book::Model{
.await
.expect("could not create book");
}
for person in doc_sent.person.as_ref().unwrap().iter() {
for person in doc_sent.person.as_ref().unwrap_or(&vec!["".to_string()]).iter() {
let record : book_person::Model = book_person::Model{
id: 1,
book_id: doc_sent.id,
@@ -881,7 +883,7 @@ let book: book::Model = book::Model{
.expect("could not create book");
}
for place in doc_sent.place.as_ref().unwrap().iter() {
for place in doc_sent.place.as_ref().unwrap_or(&vec!["".to_string()]).iter() {
let record : book_place::Model = book_place::Model{
id: 1,
book_id: doc_sent.id,
@@ -892,7 +894,7 @@ let book: book::Model = book::Model{
.expect("could not create book");
}
for subject in doc_sent.subject.as_ref().unwrap().iter() {
for subject in doc_sent.subject.as_ref().unwrap_or(&vec!["".to_string()]).iter() {
let record : book_subject::Model = book_subject::Model{
id: 1,
book_id: doc_sent.id,
@@ -903,7 +905,7 @@ let book: book::Model = book::Model{
.expect("could not create book");
}
for time in doc_sent.time.as_ref().unwrap().iter() {
for time in doc_sent.time.as_ref().unwrap_or(&vec!["".to_string()]).iter() {
let record : book_time::Model = book_time::Model{
id: 1,
book_id: doc_sent.id,
@@ -914,7 +916,7 @@ let book: book::Model = book::Model{
.expect("could not create book");
}
for isbn in doc_sent.isbn.as_ref().unwrap().iter() {
for isbn in doc_sent.isbn.as_ref().unwrap_or(&vec!["".to_string()]).iter() {
let record : book_isbn::Model = book_isbn::Model{
id: 1,
book_id: doc_sent.id,