From e8e34577100c38097a08ef877b745d09a3d7bc39 Mon Sep 17 00:00:00 2001 From: Diptesh Choudhuri Date: Wed, 18 Dec 2024 00:03:52 +0530 Subject: [PATCH 01/21] build(backend): add catch panic feature --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 6a3c6ec945..9c53114c3f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -49,7 +49,7 @@ resolver = "2" [workspace.dependencies] askama = "0.12.1" anyhow = "=1.0.93" -apalis = { version = "=0.6.2", features = ["limit"] } +apalis = { version = "=0.6.2", features = ["catch-panic", "limit"] } apalis-cron = "=0.6.2" argon2 = "=0.6.0-pre.1" async-graphql = { version = "=7.0.11", features = [ From 2f28e4178ec6ac97766439c35c0b8c84bb61812e Mon Sep 17 00:00:00 2001 From: Diptesh Choudhuri Date: Wed, 18 Dec 2024 00:04:24 +0530 Subject: [PATCH 02/21] feat(backend): catch panic from background jobs --- apps/backend/src/main.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/apps/backend/src/main.rs b/apps/backend/src/main.rs index dc86f45729..7ce0e9de35 100644 --- a/apps/backend/src/main.rs +++ b/apps/backend/src/main.rs @@ -191,6 +191,7 @@ async fn main() -> Result<()> { .register( WorkerBuilder::new("daily_background_jobs") .enable_tracing() + .catch_panic() .data(miscellaneous_service_1.clone()) .backend( // every day @@ -201,6 +202,7 @@ async fn main() -> Result<()> { .register( WorkerBuilder::new("frequent_jobs") .enable_tracing() + .catch_panic() .data(integration_service_1.clone()) .data(fitness_service_2.clone()) .backend(CronStream::new_with_timezone( @@ -213,6 +215,7 @@ async fn main() -> Result<()> { .register( WorkerBuilder::new("perform_core_application_job") .enable_tracing() + .catch_panic() .data(integration_service_2.clone()) .data(miscellaneous_service_3.clone()) .backend(perform_core_application_job_storage) @@ -221,6 +224,7 @@ async fn main() -> Result<()> { .register( WorkerBuilder::new("perform_application_job") .enable_tracing() + .catch_panic() .data(fitness_service_1.clone()) .data(exporter_service_1.clone()) .data(importer_service_1.clone()) From 072b150da3174728e84e167d8af321738ca51aee Mon Sep 17 00:00:00 2001 From: Diptesh Choudhuri Date: Wed, 18 Dec 2024 00:08:41 +0530 Subject: [PATCH 03/21] feat(services/importer): import progress and collections --- crates/services/importer/src/anilist.rs | 84 +++++++++++++++++++++---- 1 file changed, 73 insertions(+), 11 deletions(-) diff --git a/crates/services/importer/src/anilist.rs b/crates/services/importer/src/anilist.rs index 967c18d696..e127052fe1 100644 --- a/crates/services/importer/src/anilist.rs +++ b/crates/services/importer/src/anilist.rs @@ -1,8 +1,12 @@ use std::{collections::HashMap, fs}; use async_graphql::Result; -use dependent_models::ImportResult; -use media_models::DeployJsonImportInput; +use chrono::NaiveDateTime; +use dependent_models::{ImportCompletedItem, ImportResult}; +use enums::{ImportSource, MediaLot, MediaSource}; +use media_models::{ + DeployJsonImportInput, ImportOrExportMetadataItem, ImportOrExportMetadataItemSeen, +}; use nest_struct::nest_struct; use serde::Deserialize; @@ -17,12 +21,12 @@ struct AnilistExport { }, lists: Vec< nest! { - score: u8, + id: u64, progress: u8, series_id: i32, series_type: u8, - started_on: u64, - finished_on: u64, + updated_at: String, + progress_volume: u8, custom_lists: String, }, >, @@ -40,22 +44,80 @@ struct AnilistExport { pub async fn import(input: DeployJsonImportInput) -> Result { let export = fs::read_to_string(input.export)?; let data = serde_json::from_str::(&export)?; - let lists = data.user.custom_lists; - let anime_custom_lists = lists + let user_lists = data.user.custom_lists; + let mut completed = vec![]; + let anime_custom_lists = user_lists .anime .into_iter() .enumerate() - .map(|(idx, list_name)| (idx + 1, list_name)) + .map(|(idx, list_name)| (idx, list_name)) .collect::>(); - let manga_custom_lists = lists + let manga_custom_lists = user_lists .manga .into_iter() .enumerate() - .map(|(idx, list_name)| (idx + 1, list_name)) + .map(|(idx, list_name)| (idx, list_name)) .collect::>(); - dbg!(anime_custom_lists, manga_custom_lists); + for item in data.lists { + let lot = match item.series_type { + 1 => MediaLot::Manga, + _ => MediaLot::Anime, + }; + let progress = [item.progress, item.progress_volume].into_iter().max(); + let mut db_item = ImportOrExportMetadataItem { + lot, + source_id: item.id.to_string(), + identifier: item.series_id.to_string(), + source: MediaSource::Anilist, + collections: vec![], + reviews: vec![], + seen_history: vec![], + }; + for num in 1..progress.unwrap_or_default() + 1 { + let mut history = ImportOrExportMetadataItemSeen { + provider_watched_on: Some(ImportSource::Anilist.to_string()), + ended_on: Some(parse_date_string(&item.updated_at).date()), + ..Default::default() + }; + match lot { + MediaLot::Anime => { + history.anime_episode_number = Some(num.try_into().unwrap()); + } + MediaLot::Manga => { + history.manga_chapter_number = Some(num.try_into().unwrap()); + } + _ => unreachable!(), + } + db_item.seen_history.push(history); + } + let in_lists = serde_json::from_str::>(&item.custom_lists)?; + for in_list in in_lists.iter() { + match lot { + MediaLot::Anime => { + if let Some(list) = anime_custom_lists.get(in_list) { + db_item.collections.push(list.clone()); + } + } + MediaLot::Manga => { + if let Some(list) = manga_custom_lists.get(in_list) { + db_item.collections.push(list.clone()); + } + } + _ => unreachable!(), + } + } + if !db_item.seen_history.is_empty() && !db_item.collections.is_empty() { + completed.push(ImportCompletedItem::Metadata(db_item)); + } + } + dbg!(&completed); todo!(); Ok(ImportResult { + completed, ..Default::default() }) } + +fn parse_date_string(input: &str) -> NaiveDateTime { + NaiveDateTime::parse_from_str(input, "%Y-%m-%d %H:%M:%S").unwrap() +} From 36fac3755b3d13f5121f89a8d9044dc0c63be72b Mon Sep 17 00:00:00 2001 From: Diptesh Choudhuri Date: Wed, 18 Dec 2024 09:31:37 +0530 Subject: [PATCH 04/21] feat(services/importer): complete anilist exporter --- crates/services/importer/src/anilist.rs | 73 ++++++++++++++++++++----- crates/services/importer/src/lib.rs | 2 +- 2 files changed, 59 insertions(+), 16 deletions(-) diff --git a/crates/services/importer/src/anilist.rs b/crates/services/importer/src/anilist.rs index e127052fe1..111f0a293d 100644 --- a/crates/services/importer/src/anilist.rs +++ b/crates/services/importer/src/anilist.rs @@ -1,14 +1,33 @@ -use std::{collections::HashMap, fs}; +use std::{collections::HashMap, fs, sync::Arc}; use async_graphql::Result; use chrono::NaiveDateTime; use dependent_models::{ImportCompletedItem, ImportResult}; -use enums::{ImportSource, MediaLot, MediaSource}; +use enums::{ImportSource, MediaLot, MediaSource, Visibility}; use media_models::{ - DeployJsonImportInput, ImportOrExportMetadataItem, ImportOrExportMetadataItemSeen, + DeployJsonImportInput, ImportOrExportItemRating, ImportOrExportItemReview, + ImportOrExportMetadataItem, ImportOrExportMetadataItemSeen, }; use nest_struct::nest_struct; +use rust_decimal::Decimal; use serde::Deserialize; +use supporting_service::SupportingService; + +use super::utils; + +fn anilist_series_type_to_lot(series_type: u8) -> MediaLot { + match series_type { + 1 => MediaLot::Manga, + _ => MediaLot::Anime, + } +} + +fn anilist_private_status_to_visibility(private: u8) -> Visibility { + match private { + 1 => Visibility::Private, + _ => Visibility::Public, + } +} #[nest_struct] #[derive(Debug, Deserialize)] @@ -32,16 +51,22 @@ struct AnilistExport { >, reviews: Vec< nest! { - score: u8, + id: u64, private: u8, text: String, series_id: i32, + score: Decimal, summary: String, + series_type: u8, + updated_at: String, }, >, } -pub async fn import(input: DeployJsonImportInput) -> Result { +pub async fn import( + input: DeployJsonImportInput, + ss: &Arc, +) -> Result { let export = fs::read_to_string(input.export)?; let data = serde_json::from_str::(&export)?; let user_lists = data.user.custom_lists; @@ -59,19 +84,14 @@ pub async fn import(input: DeployJsonImportInput) -> Result { .map(|(idx, list_name)| (idx, list_name)) .collect::>(); for item in data.lists { - let lot = match item.series_type { - 1 => MediaLot::Manga, - _ => MediaLot::Anime, - }; let progress = [item.progress, item.progress_volume].into_iter().max(); + let lot = anilist_series_type_to_lot(item.series_type); let mut db_item = ImportOrExportMetadataItem { lot, + source: MediaSource::Anilist, source_id: item.id.to_string(), identifier: item.series_id.to_string(), - source: MediaSource::Anilist, - collections: vec![], - reviews: vec![], - seen_history: vec![], + ..Default::default() }; for num in 1..progress.unwrap_or_default() + 1 { let mut history = ImportOrExportMetadataItemSeen { @@ -110,8 +130,31 @@ pub async fn import(input: DeployJsonImportInput) -> Result { completed.push(ImportCompletedItem::Metadata(db_item)); } } - dbg!(&completed); - todo!(); + for review in data.reviews { + let lot = anilist_series_type_to_lot(review.series_type); + let visibility = anilist_private_status_to_visibility(review.private); + let entire_text = format!("{}\n\n{}", review.summary, review.text); + completed.push(ImportCompletedItem::Metadata(ImportOrExportMetadataItem { + lot, + source: MediaSource::Anilist, + source_id: review.id.to_string(), + identifier: review.series_id.to_string(), + reviews: vec![ImportOrExportItemRating { + rating: Some(review.score), + review: Some(ImportOrExportItemReview { + text: Some(entire_text), + visibility: Some(visibility), + date: Some(utils::get_date_time_with_offset( + parse_date_string(&review.updated_at), + &ss.timezone, + )), + ..Default::default() + }), + ..Default::default() + }], + ..Default::default() + })); + } Ok(ImportResult { completed, ..Default::default() diff --git a/crates/services/importer/src/lib.rs b/crates/services/importer/src/lib.rs index 5379d6ae27..157abef619 100644 --- a/crates/services/importer/src/lib.rs +++ b/crates/services/importer/src/lib.rs @@ -81,7 +81,7 @@ impl ImporterService { let import_id = db_import_job.id.clone(); ryot_log!(debug, "Started import job with id {import_id}"); let maybe_import = match input.source { - ImportSource::Anilist => anilist::import(input.generic_json.unwrap()).await, + ImportSource::Anilist => anilist::import(input.generic_json.unwrap(), &self.0).await, ImportSource::StrongApp => { strong_app::import(input.strong_app.unwrap(), &self.0, &user_id).await } From 3a34d80eb210ea13e858864d7eed0acf1aeefdb2 Mon Sep 17 00:00:00 2001 From: Diptesh Choudhuri Date: Wed, 18 Dec 2024 09:33:47 +0530 Subject: [PATCH 05/21] ci: Run CI From 98ede9e4615f7043b6ec7342e0d742efbeea6ca8 Mon Sep 17 00:00:00 2001 From: Diptesh Choudhuri Date: Wed, 18 Dec 2024 09:38:02 +0530 Subject: [PATCH 06/21] chore(frontend): change order of stats --- apps/frontend/app/routes/_dashboard.analytics.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/frontend/app/routes/_dashboard.analytics.tsx b/apps/frontend/app/routes/_dashboard.analytics.tsx index 2f99c66c1d..5229ea49df 100644 --- a/apps/frontend/app/routes/_dashboard.analytics.tsx +++ b/apps/frontend/app/routes/_dashboard.analytics.tsx @@ -258,12 +258,12 @@ export default function Page() { - - - + + + )} {isCaptureLoading ? ( From 4b7ceeda4bfb939e89d8e0632f55acea2b06fd27 Mon Sep 17 00:00:00 2001 From: Diptesh Choudhuri Date: Wed, 18 Dec 2024 18:48:17 +0530 Subject: [PATCH 07/21] chore(frontend): change order of analytics cards --- apps/frontend/app/routes/_dashboard.analytics.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/frontend/app/routes/_dashboard.analytics.tsx b/apps/frontend/app/routes/_dashboard.analytics.tsx index 5229ea49df..c89bf4aaca 100644 --- a/apps/frontend/app/routes/_dashboard.analytics.tsx +++ b/apps/frontend/app/routes/_dashboard.analytics.tsx @@ -255,15 +255,15 @@ export default function Page() { + + + - - - )} {isCaptureLoading ? ( From 0a2cfaa8ac09f282d979a0eb5687ff233ed46d87 Mon Sep 17 00:00:00 2001 From: Diptesh Choudhuri Date: Wed, 18 Dec 2024 18:55:11 +0530 Subject: [PATCH 08/21] fix(frontend): change page title of analytics page --- apps/frontend/app/routes/_dashboard.analytics.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/frontend/app/routes/_dashboard.analytics.tsx b/apps/frontend/app/routes/_dashboard.analytics.tsx index c89bf4aaca..8206838d5e 100644 --- a/apps/frontend/app/routes/_dashboard.analytics.tsx +++ b/apps/frontend/app/routes/_dashboard.analytics.tsx @@ -109,7 +109,7 @@ export const loader = async ({ request }: LoaderFunctionArgs) => { }; export const meta = (_args: MetaArgs) => { - return [{ title: "Fitness Analytics | Ryot" }]; + return [{ title: "Analytics | Ryot" }]; }; const useTimeSpanSettings = () => { From a433e0c88c8b5580efb65aede1b88d68ec7b75ca Mon Sep 17 00:00:00 2001 From: Diptesh Choudhuri Date: Wed, 18 Dec 2024 18:58:48 +0530 Subject: [PATCH 09/21] refactor(services/supporting): collapse match branches --- crates/services/supporting/src/lib.rs | 42 ++++++--------------------- 1 file changed, 9 insertions(+), 33 deletions(-) diff --git a/crates/services/supporting/src/lib.rs b/crates/services/supporting/src/lib.rs index 8b9d01be85..78ad9ab927 100644 --- a/crates/services/supporting/src/lib.rs +++ b/crates/services/supporting/src/lib.rs @@ -195,45 +195,21 @@ impl SupportingService { .collect(), "us".to_owned(), ), - MediaSource::Openlibrary => ( - ["us"].into_iter().map(String::from).collect(), - "us".to_owned(), - ), MediaSource::Tmdb => ( isolang::languages() .filter_map(|l| l.to_639_1().map(String::from)) .collect(), "en".to_owned(), ), - MediaSource::Listennotes => ( - ["us"].into_iter().map(String::from).collect(), - "us".to_owned(), - ), - MediaSource::GoogleBooks => (vec!["us".to_owned()], "us".to_owned()), - MediaSource::Igdb => ( - ["us"].into_iter().map(String::from).collect(), - "us".to_owned(), - ), - MediaSource::MangaUpdates => ( - ["us"].into_iter().map(String::from).collect(), - "us".to_owned(), - ), - MediaSource::Anilist => ( - ["us"].into_iter().map(String::from).collect(), - "us".to_owned(), - ), - MediaSource::Mal => ( - ["us"].into_iter().map(String::from).collect(), - "us".to_owned(), - ), - MediaSource::Custom => ( - ["us"].into_iter().map(String::from).collect(), - "us".to_owned(), - ), - MediaSource::Vndb => ( - ["us"].into_iter().map(String::from).collect(), - "us".to_owned(), - ), + MediaSource::GoogleBooks + | MediaSource::Listennotes + | MediaSource::Openlibrary + | MediaSource::Igdb + | MediaSource::MangaUpdates + | MediaSource::Anilist + | MediaSource::Mal + | MediaSource::Custom + | MediaSource::Vndb => (vec!["us".to_owned()], "us".to_owned()), }; ProviderLanguageInformation { source, From 2ea5efbed8133aff8c4c31b48be987953628d7cb Mon Sep 17 00:00:00 2001 From: Diptesh Choudhuri Date: Wed, 18 Dec 2024 19:01:03 +0530 Subject: [PATCH 10/21] chore(backend): remove useless code --- Cargo.lock | 3 --- apps/backend/Cargo.toml | 1 - crates/background/Cargo.toml | 1 - crates/services/supporting/Cargo.toml | 1 - crates/services/supporting/src/lib.rs | 2 -- 5 files changed, 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a01137553a..531b6afd19 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -848,7 +848,6 @@ dependencies = [ "statistics-service", "supporting-service", "tokio", - "tower", "tower-http", "tracing", "tracing-subscriber", @@ -861,7 +860,6 @@ dependencies = [ name = "background" version = "0.1.0" dependencies = [ - "apalis", "chrono", "chrono-tz", "database-models", @@ -6310,7 +6308,6 @@ dependencies = [ "sea-orm", "serde", "serde_json", - "serde_with 3.11.0", "tracing", "unkey", ] diff --git a/apps/backend/Cargo.toml b/apps/backend/Cargo.toml index c7b0d42357..81bee2a925 100644 --- a/apps/backend/Cargo.toml +++ b/apps/backend/Cargo.toml @@ -52,7 +52,6 @@ statistics-resolver = { path = "../../crates/resolvers/statistics" } statistics-service = { path = "../../crates/services/statistics" } supporting-service = { path = "../../crates/services/supporting" } tokio = { workspace = true } -tower = { workspace = true } tower-http = { workspace = true } tracing = { workspace = true } tracing-subscriber = { workspace = true } diff --git a/crates/background/Cargo.toml b/crates/background/Cargo.toml index 03a49d4361..2b52312894 100644 --- a/crates/background/Cargo.toml +++ b/crates/background/Cargo.toml @@ -4,7 +4,6 @@ version = "0.1.0" edition = "2021" [dependencies] -apalis = { workspace = true } chrono = { workspace = true } chrono-tz = { workspace = true } database-models = { path = "../models/database" } diff --git a/crates/services/supporting/Cargo.toml b/crates/services/supporting/Cargo.toml index 84a4e09e6f..a4963ef1fd 100644 --- a/crates/services/supporting/Cargo.toml +++ b/crates/services/supporting/Cargo.toml @@ -25,7 +25,6 @@ rustypipe = { workspace = true } sea-orm = { workspace = true } serde = { workspace = true } serde_json = { workspace = true } -serde_with = { workspace = true } tracing = { workspace = true } unkey = { workspace = true } diff --git a/crates/services/supporting/src/lib.rs b/crates/services/supporting/src/lib.rs index 78ad9ab927..51c5662272 100644 --- a/crates/services/supporting/src/lib.rs +++ b/crates/services/supporting/src/lib.rs @@ -26,7 +26,6 @@ use openidconnect::core::CoreClient; use rustypipe::param::{Language, LANGUAGES}; use sea_orm::{DatabaseConnection, EntityTrait, Iterable, PaginatorTrait}; use serde::{Deserialize, Serialize}; -use serde_with::skip_serializing_none; use unkey::{models::VerifyKeyRequest, Client}; pub struct SupportingService { @@ -90,7 +89,6 @@ impl SupportingService { } ryot_log!(debug, "Verifying pro key for API ID: {:#?}", UNKEY_API_ID); let compile_timestamp = Utc.timestamp_opt(COMPILATION_TIMESTAMP, 0).unwrap(); - #[skip_serializing_none] #[derive(Debug, Serialize, Clone, Deserialize)] struct Meta { expiry: Option, From 4006073979a5a15d180943cfb688dca2a0a97c41 Mon Sep 17 00:00:00 2001 From: Diptesh Choudhuri Date: Wed, 18 Dec 2024 19:05:43 +0530 Subject: [PATCH 11/21] refactor(backend): call jobs in parallel --- apps/backend/src/common.rs | 6 ++++-- apps/backend/src/main.rs | 21 ++++++++++----------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/apps/backend/src/common.rs b/apps/backend/src/common.rs index 03fd996ebd..d95440c1cf 100644 --- a/apps/backend/src/common.rs +++ b/apps/backend/src/common.rs @@ -47,9 +47,10 @@ use user_service::UserService; /// All the services that are used by the app pub struct AppServices { pub app_router: Router, + pub fitness_service: Arc, pub importer_service: Arc, pub exporter_service: Arc, - pub fitness_service: Arc, + pub supporting_service: Arc, pub statistics_service: Arc, pub integration_service: Arc, pub miscellaneous_service: Arc, @@ -145,9 +146,10 @@ pub async fn create_app_services( .layer(cors); AppServices { app_router, + fitness_service, importer_service, exporter_service, - fitness_service, + supporting_service, statistics_service, integration_service, miscellaneous_service, diff --git a/apps/backend/src/main.rs b/apps/backend/src/main.rs index 7ce0e9de35..b3cb8d58ff 100644 --- a/apps/backend/src/main.rs +++ b/apps/backend/src/main.rs @@ -10,7 +10,7 @@ use std::{ use anyhow::{bail, Result}; use apalis::{ layers::{limit::RateLimitLayer as ApalisRateLimitLayer, WorkerBuilderExt}, - prelude::{MemoryStorage, MessageQueue, Monitor, WorkerBuilder, WorkerFactoryFn}, + prelude::{MemoryStorage, Monitor, WorkerBuilder, WorkerFactoryFn}, }; use apalis_cron::{CronStream, Schedule}; use aws_sdk_s3::config::Region; @@ -115,16 +115,6 @@ async fn main() -> Result<()> { .unwrap_or_else(|_| chrono_tz::Etc::GMT); ryot_log!(info, "Timezone: {}", tz); - join_all([ - perform_application_job_storage - .clone() - .enqueue(ApplicationJob::SyncIntegrationsData), - perform_application_job_storage - .clone() - .enqueue(ApplicationJob::UpdateExerciseLibrary), - ]) - .await; - let app_services = create_app_services( db, tz, @@ -135,6 +125,15 @@ async fn main() -> Result<()> { ) .await; + join_all( + [ + ApplicationJob::SyncIntegrationsData, + ApplicationJob::UpdateExerciseLibrary, + ] + .map(|job| app_services.supporting_service.perform_application_job(job)), + ) + .await; + if cfg!(debug_assertions) { use dependent_models::CompleteExport; use schematic::schema::{SchemaGenerator, TypeScriptRenderer, YamlTemplateRenderer}; From fbaa6d35cfd57bd1e52c51919f5d62bd469915bc Mon Sep 17 00:00:00 2001 From: Diptesh Choudhuri Date: Wed, 18 Dec 2024 19:15:20 +0530 Subject: [PATCH 12/21] chore(frontend): remove ios code --- apps/frontend/app/root.tsx | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/apps/frontend/app/root.tsx b/apps/frontend/app/root.tsx index 88b8965aed..0eec216f8c 100644 --- a/apps/frontend/app/root.tsx +++ b/apps/frontend/app/root.tsx @@ -102,24 +102,10 @@ export const loader = async ({ request }: LoaderFunctionArgs) => { const defaultColorScheme = colorScheme || "light"; if (toastHeaders) extendResponseHeaders(headers, toastHeaders); - const userAgent = request.headers.get("user-agent") || ""; - const isIOS = /iPad|iPhone|iPod/.test(userAgent); - let isIOS18 = false; - - if (isIOS) { - const match = userAgent.match(/OS (\d+)_(\d+)_?(\d+)?/); - if (match) { - const version = Number.parseInt(match[1], 10); - isIOS18 = version >= 18; - } - } - - return data({ toast, defaultColorScheme, isIOS18 }, { headers }); + return data({ toast, defaultColorScheme }, { headers }); }; const DefaultHeadTags = () => { - const loaderData = useLoaderData(); - return ( <> @@ -128,12 +114,7 @@ const DefaultHeadTags = () => { content="minimum-scale=1, initial-scale=1, width=device-width, shrink-to-fit=no, user-scalable=no, viewport-fit=cover" /> - + ); }; From 8c4dcf5eef8ee568753504ec36afe02efd984b54 Mon Sep 17 00:00:00 2001 From: Diptesh Choudhuri Date: Wed, 18 Dec 2024 19:17:49 +0530 Subject: [PATCH 13/21] refactor(frontend): remove duplicated code --- apps/frontend/app/root.tsx | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/apps/frontend/app/root.tsx b/apps/frontend/app/root.tsx index 0eec216f8c..fa5f603cca 100644 --- a/apps/frontend/app/root.tsx +++ b/apps/frontend/app/root.tsx @@ -134,18 +134,17 @@ export default function App() { - {navigation.state === "loading" || - navigation.state === "submitting" ? ( + {["loading", "submitting"].includes(navigation.state) ? ( From 23704a6a80c0b9f7626c51b59b0e7f929ef7a06e Mon Sep 17 00:00:00 2001 From: Diptesh Choudhuri Date: Wed, 18 Dec 2024 19:20:29 +0530 Subject: [PATCH 14/21] refactor(backend): move imports above --- apps/backend/src/main.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/apps/backend/src/main.rs b/apps/backend/src/main.rs index b3cb8d58ff..4bf04e789f 100644 --- a/apps/backend/src/main.rs +++ b/apps/backend/src/main.rs @@ -16,10 +16,12 @@ use apalis_cron::{CronStream, Schedule}; use aws_sdk_s3::config::Region; use background::ApplicationJob; use common_utils::{ryot_log, PROJECT_NAME, TEMP_DIR}; +use dependent_models::CompleteExport; use env_utils::APP_VERSION; use futures::future::join_all; use logs_wheel::LogFileInitializer; use migrations::Migrator; +use schematic::schema::{SchemaGenerator, TypeScriptRenderer, YamlTemplateRenderer}; use sea_orm::{ConnectionTrait, Database, DatabaseConnection}; use sea_orm_migration::MigratorTrait; use tokio::{ @@ -135,9 +137,6 @@ async fn main() -> Result<()> { .await; if cfg!(debug_assertions) { - use dependent_models::CompleteExport; - use schematic::schema::{SchemaGenerator, TypeScriptRenderer, YamlTemplateRenderer}; - // TODO: Once https://github.com/rust-lang/cargo/issues/3946 is resolved let base_dir = PathBuf::from(BASE_DIR) .parent() @@ -254,9 +253,9 @@ fn init_tracing() -> Result<()> { let tmp_dir = PathBuf::new().join(TEMP_DIR); create_dir_all(&tmp_dir)?; let log_file = LogFileInitializer { + max_n_old_files: 2, directory: tmp_dir, filename: PROJECT_NAME, - max_n_old_files: 2, preferred_max_file_size_mib: 1, } .init()?; From fff9086ad5d15f6cbd3d52fcf0873c546335f816 Mon Sep 17 00:00:00 2001 From: Diptesh Choudhuri Date: Wed, 18 Dec 2024 19:21:43 +0530 Subject: [PATCH 15/21] ci: Run CI From 5803f7b6bd7b91a502e3c4e915a03874de7435bc Mon Sep 17 00:00:00 2001 From: Diptesh Choudhuri Date: Thu, 19 Dec 2024 09:10:16 +0530 Subject: [PATCH 16/21] fix(services/importer): use correct condition --- crates/services/importer/src/anilist.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/services/importer/src/anilist.rs b/crates/services/importer/src/anilist.rs index 111f0a293d..8102a80ba4 100644 --- a/crates/services/importer/src/anilist.rs +++ b/crates/services/importer/src/anilist.rs @@ -69,6 +69,7 @@ pub async fn import( ) -> Result { let export = fs::read_to_string(input.export)?; let data = serde_json::from_str::(&export)?; + dbg!(&data); let user_lists = data.user.custom_lists; let mut completed = vec![]; let anime_custom_lists = user_lists @@ -126,7 +127,7 @@ pub async fn import( _ => unreachable!(), } } - if !db_item.seen_history.is_empty() && !db_item.collections.is_empty() { + if !db_item.seen_history.is_empty() || !db_item.collections.is_empty() { completed.push(ImportCompletedItem::Metadata(db_item)); } } From 50c77560925c6807e17b10eb91db96191c05c4a8 Mon Sep 17 00:00:00 2001 From: Diptesh Choudhuri Date: Thu, 19 Dec 2024 09:10:20 +0530 Subject: [PATCH 17/21] ci: Run CI From a0985f1096530c7aac87e480a04a6fba0cb621ee Mon Sep 17 00:00:00 2001 From: Diptesh Choudhuri Date: Thu, 19 Dec 2024 09:11:27 +0530 Subject: [PATCH 18/21] chore(services/importer): remove useless `dbg!` statement --- crates/services/importer/src/anilist.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/services/importer/src/anilist.rs b/crates/services/importer/src/anilist.rs index 8102a80ba4..a079020237 100644 --- a/crates/services/importer/src/anilist.rs +++ b/crates/services/importer/src/anilist.rs @@ -69,7 +69,6 @@ pub async fn import( ) -> Result { let export = fs::read_to_string(input.export)?; let data = serde_json::from_str::(&export)?; - dbg!(&data); let user_lists = data.user.custom_lists; let mut completed = vec![]; let anime_custom_lists = user_lists From 270611e6ed3fa3bc99b95e3e6a5993b7fc5cb1ff Mon Sep 17 00:00:00 2001 From: Diptesh Choudhuri Date: Thu, 19 Dec 2024 12:34:21 +0530 Subject: [PATCH 19/21] chore(frontend): highlight image only when server key is validated --- apps/frontend/app/components/common.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/frontend/app/components/common.tsx b/apps/frontend/app/components/common.tsx index 1f2fb8cd69..542bfaf44a 100644 --- a/apps/frontend/app/components/common.tsx +++ b/apps/frontend/app/components/common.tsx @@ -267,6 +267,7 @@ export const BaseMediaDisplayItem = (props: { bottomLeft?: ReactNode; }; }) => { + const coreDetails = useCoreDetails(); const userPreferences = useUserPreferences(); const gridPacking = userPreferences.general.gridPacking; const SurroundingElement = (iProps: { children: ReactNode }) => @@ -292,7 +293,8 @@ export const BaseMediaDisplayItem = (props: { pos="relative" style={{ overflow: "hidden" }} className={clsx({ - [classes.highlightImage]: props.highlightImage, + [classes.highlightImage]: + coreDetails.isServerKeyValidated && props.highlightImage, })} > Date: Thu, 19 Dec 2024 12:45:43 +0530 Subject: [PATCH 20/21] feat(frontend): animate the application grid --- apps/frontend/app/components/common.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/frontend/app/components/common.tsx b/apps/frontend/app/components/common.tsx index 542bfaf44a..394a6c1ad2 100644 --- a/apps/frontend/app/components/common.tsx +++ b/apps/frontend/app/components/common.tsx @@ -1,5 +1,6 @@ import { Carousel } from "@mantine/carousel"; import "@mantine/carousel/styles.css"; +import { useAutoAnimate } from "@formkit/auto-animate/react"; import { ActionIcon, Alert, @@ -104,14 +105,16 @@ export const ApplicationGrid = (props: { children: ReactNode | Array; }) => { const userPreferences = useUserPreferences(); + const [parent] = useAutoAnimate(); return ( ({ base: 2, sm: 3, md: 4, lg: 5 })) .with(GridPacking.Dense, () => ({ base: 3, sm: 4, md: 5, lg: 6 })) .exhaustive()} - spacing="lg" > {props.children} From 79bcf8ab4a4c4fca2b7d1e8245d9b1452c6cef1e Mon Sep 17 00:00:00 2001 From: Diptesh Choudhuri Date: Thu, 19 Dec 2024 14:56:11 +0530 Subject: [PATCH 21/21] chore(services/importer): better error message for failed item for plex --- crates/services/importer/src/plex.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/services/importer/src/plex.rs b/crates/services/importer/src/plex.rs index 5c32047d61..804d72757a 100644 --- a/crates/services/importer/src/plex.rs +++ b/crates/services/importer/src/plex.rs @@ -63,8 +63,8 @@ pub async fn import(input: DeployUrlAndKeyImportInput) -> Result { else { failed_items.push(ImportFailedItem { lot: Some(lot), - identifier: item.key.clone(), step: ImportFailStep::ItemDetailsFromSource, + identifier: format!("{} ({}) - {}", item.title, lot, item.key), error: Some("No TMDb ID associated with this media".to_string()), }); continue;