v0.15-WORKINGV4
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user