refactor(card_database): Accurately name card database
This commit is contained in:
parent
3df19c8496
commit
cc27ab5b6d
src
|
@ -14,14 +14,14 @@
|
|||
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with yugioh-binder. If not, see <https://www.gnu.org/licenses/>.
|
||||
use draft_manager::database::BrowserDatabase;
|
||||
use draft_manager::card_database::CardDatabase;
|
||||
|
||||
fn main() {
|
||||
console_error_panic_hook::set_once();
|
||||
wasm_logger::init(wasm_logger::Config::default());
|
||||
|
||||
wasm_bindgen_futures::spawn_local(async {
|
||||
let a = BrowserDatabase::init_worker().await;
|
||||
let a = CardDatabase::init_worker().await;
|
||||
|
||||
if let Err(e) = a {
|
||||
log::error!("{:?}", e);
|
||||
|
|
|
@ -20,13 +20,13 @@ pub mod models;
|
|||
pub mod schema;
|
||||
mod worker;
|
||||
|
||||
use worker::{BrowserDatabaseError, DatabaseWorker, Query};
|
||||
use worker::{CardDatabaseWorkerError, DatabaseWorker, Query};
|
||||
|
||||
pub struct BrowserDatabase {
|
||||
pub struct CardDatabase {
|
||||
worker: WorkerBridge<DatabaseWorker>,
|
||||
}
|
||||
|
||||
impl BrowserDatabase {
|
||||
impl CardDatabase {
|
||||
pub fn new() -> Self {
|
||||
let bridge = DatabaseWorker::spawner()
|
||||
.callback(move |o| {
|
||||
|
@ -46,7 +46,7 @@ impl BrowserDatabase {
|
|||
/// Initialize the database worker.
|
||||
///
|
||||
/// Must be executed in a worker script, not on the main thread.
|
||||
pub async fn init_worker() -> Result<(), BrowserDatabaseError> {
|
||||
pub async fn init_worker() -> Result<(), CardDatabaseWorkerError> {
|
||||
log::debug!("Initializing database worker...");
|
||||
DatabaseWorker::initialize_db().await?;
|
||||
DatabaseWorker::registrar().register();
|
||||
|
@ -55,7 +55,7 @@ impl BrowserDatabase {
|
|||
}
|
||||
}
|
||||
|
||||
impl Default for BrowserDatabase {
|
||||
impl Default for CardDatabase {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
|
@ -17,8 +17,8 @@
|
|||
use diesel::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::database::schema::datas;
|
||||
use crate::database::schema::texts;
|
||||
use super::schema::datas;
|
||||
use super::schema::texts;
|
||||
|
||||
#[derive(Debug, Selectable, Queryable)]
|
||||
#[diesel(table_name = datas)]
|
|
@ -160,7 +160,7 @@ async fn should_update_card_db() -> Result<bool> {
|
|||
let last_update = {
|
||||
let ts = read_opfs_file("last_update.txt").await?;
|
||||
if !ts.is_empty() {
|
||||
OffsetDateTime::parse(&ts, &Rfc3339).map_err(BrowserDatabaseError::from)
|
||||
OffsetDateTime::parse(&ts, &Rfc3339).map_err(CardDatabaseWorkerError::from)
|
||||
} else {
|
||||
Ok(OffsetDateTime::UNIX_EPOCH)
|
||||
}
|
||||
|
@ -193,7 +193,7 @@ async fn update_card_db(sah_pool_util: &OpfsSAHPoolUtil) -> Result<()> {
|
|||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum BrowserDatabaseError {
|
||||
pub enum CardDatabaseWorkerError {
|
||||
#[error("failed to connect to database")]
|
||||
DieselConnectionError(#[from] diesel::ConnectionError),
|
||||
#[error("failed to query database")]
|
||||
|
@ -210,4 +210,4 @@ pub enum BrowserDatabaseError {
|
|||
#[error("failed to write last Babel DB update date")]
|
||||
TimeFormatError(#[from] time::error::Format),
|
||||
}
|
||||
type Result<T> = std::result::Result<T, BrowserDatabaseError>;
|
||||
type Result<T> = std::result::Result<T, CardDatabaseWorkerError>;
|
|
@ -16,7 +16,7 @@
|
|||
// along with yugioh-binder. If not, see <https://www.gnu.org/licenses/>.
|
||||
use leptos::prelude::*;
|
||||
|
||||
use crate::database::models::CardData;
|
||||
use crate::card_database::models::CardData;
|
||||
|
||||
#[component]
|
||||
pub fn Card(details: Option<CardData>) -> impl IntoView {
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with yugioh-binder. If not, see <https://www.gnu.org/licenses/>.
|
||||
pub mod card_database;
|
||||
pub mod components;
|
||||
pub mod database;
|
||||
pub mod draft_list;
|
||||
pub mod utils;
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
// along with yugioh-binder. If not, see <https://www.gnu.org/licenses/>.
|
||||
use std::time::Duration;
|
||||
|
||||
use draft_manager::database::BrowserDatabase;
|
||||
use draft_manager::card_database::CardDatabase;
|
||||
use leptos::prelude::*;
|
||||
use wasm_bindgen_futures::spawn_local;
|
||||
|
||||
|
@ -25,7 +25,7 @@ fn main() {
|
|||
wasm_logger::init(wasm_logger::Config::default());
|
||||
|
||||
log::debug!("Startin app database");
|
||||
let db = BrowserDatabase::new();
|
||||
let db = CardDatabase::new();
|
||||
log::debug!("Database initialized");
|
||||
|
||||
leptos::mount::mount_to_body(|| view! { <App /> });
|
||||
|
|
Loading…
Reference in a new issue