From 1b5bdadf10b4d06187ce080dd555d3fb60a5e754 Mon Sep 17 00:00:00 2001 From: lonelyhentxi Date: Sat, 14 Jun 2025 22:30:58 +0800 Subject: [PATCH] fix: fix tasks --- Cargo.lock | 9 ++--- Cargo.toml | 4 +- .../proxy/.whistle/rules/files/1.mikan_doppel | 2 +- apps/proxy/src/bin/mikan_doppel.rs | 2 +- apps/recorder/.env | 1 + apps/recorder/.env.dev | 17 +++++++++ apps/recorder/Cargo.toml | 7 +++- apps/recorder/src/extract/mikan/web.rs | 1 + apps/recorder/src/task/service.rs | 9 ++++- apps/webui/.gitignore | 1 + .../src/components/ui/detail-empty-view.tsx | 38 ++++++++++++------- apps/webui/src/infra/graphql/gql/graphql.ts | 18 ++++----- .../presentation/routes/_app/tasks/manage.tsx | 2 +- justfile | 7 ++-- pnpm-workspace.yaml | 22 +++++------ 15 files changed, 91 insertions(+), 49 deletions(-) create mode 100644 apps/recorder/.env.dev diff --git a/Cargo.lock b/Cargo.lock index 61115e5..1e51be3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5388,9 +5388,9 @@ dependencies = [ [[package]] name = "reqwest" -version = "0.12.19" +version = "0.12.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2f8e5513d63f2e5b386eb5106dc67eaf3f84e95258e210489136b8b92ad6119" +checksum = "eabf4c97d9130e2bf606614eb937e86edac8292eaa6f422f995d7e8de1eb1813" dependencies = [ "base64 0.22.1", "bytes", @@ -5407,13 +5407,11 @@ dependencies = [ "hyper-rustls", "hyper-tls", "hyper-util", - "ipnet", "js-sys", "log", "mime", "mime_guess", "native-tls", - "once_cell", "percent-encoding", "pin-project-lite", "quinn", @@ -5426,7 +5424,6 @@ dependencies = [ "tokio", "tokio-native-tls", "tokio-rustls", - "tokio-socks", "tokio-util", "tower", "tower-http", @@ -5995,7 +5992,7 @@ checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" [[package]] name = "seaography" version = "1.1.4" -source = "git+https://github.com/dumtruck/seaography.git?rev=01d3f99#01d3f99aebd476860b9c061676b2b22083188b03" +source = "git+https://github.com/dumtruck/seaography.git?rev=a787c3a#a787c3ab83cf1f8275894e1bc1ca3c766b54674b" dependencies = [ "async-graphql", "fnv", diff --git a/Cargo.toml b/Cargo.toml index 9d94ca0..68a9c2a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,7 +28,7 @@ downloader = { path = "./packages/downloader" } recorder = { path = "./apps/recorder" } proxy = { path = "./apps/proxy" } -reqwest = { version = "0.12", features = [ +reqwest = { version = "0.12.20", features = [ "charset", "http2", "json", @@ -69,4 +69,4 @@ color-eyre = "0.6.5" inquire = "0.7.5" [patch.crates-io] -seaography = { git = "https://github.com/dumtruck/seaography.git", rev = "01d3f99" } +seaography = { git = "https://github.com/dumtruck/seaography.git", rev = "a787c3a" } diff --git a/apps/proxy/.whistle/rules/files/1.mikan_doppel b/apps/proxy/.whistle/rules/files/1.mikan_doppel index 161df68..8486f25 100644 --- a/apps/proxy/.whistle/rules/files/1.mikan_doppel +++ b/apps/proxy/.whistle/rules/files/1.mikan_doppel @@ -1 +1 @@ -^https://mikanani.me/*** http://127.0.0.1:5010/$1 \ No newline at end of file +^https://mikanani.me/*** http://127.0.0.1:5005/$1 \ No newline at end of file diff --git a/apps/proxy/src/bin/mikan_doppel.rs b/apps/proxy/src/bin/mikan_doppel.rs index 8b903e1..cccb5ba 100644 --- a/apps/proxy/src/bin/mikan_doppel.rs +++ b/apps/proxy/src/bin/mikan_doppel.rs @@ -10,7 +10,7 @@ async fn main() -> RecorderResult<()> { .with_max_level(Level::DEBUG) .init(); - let mut mikan_server = MikanMockServer::new_with_port(5010).await.unwrap(); + let mut mikan_server = MikanMockServer::new_with_port(5005).await.unwrap(); let resources_mock = mikan_server.mock_resources_with_doppel(); diff --git a/apps/recorder/.env b/apps/recorder/.env index b0abc9b..99d670f 100644 --- a/apps/recorder/.env +++ b/apps/recorder/.env @@ -14,3 +14,4 @@ BASIC_PASSWORD = "konobangu" # MIKAN_PROXY = "" # MIKAN_PROXY_AUTH_HEADER = "" # MIKAN_NO_PROXY = "" +# MIKAN_PROXY_ACCEPT_INVALID_CERTS = "true" diff --git a/apps/recorder/.env.dev b/apps/recorder/.env.dev new file mode 100644 index 0000000..be63e0d --- /dev/null +++ b/apps/recorder/.env.dev @@ -0,0 +1,17 @@ +HOST="konobangu.com" +DATABASE_URL = "postgres://konobangu:konobangu@localhost:5432/konobangu" +STORAGE_DATA_DIR = "./data" +AUTH_TYPE = "basic" # or oidc +BASIC_USER = "konobangu" +BASIC_PASSWORD = "konobangu" +# OIDC_ISSUER="https://auth.logto.io/oidc" +# OIDC_AUDIENCE = "https://konobangu.com/api" +# OIDC_CLIENT_ID = "client_id" +# OIDC_CLIENT_SECRET = "client_secret" # optional +# OIDC_EXTRA_SCOPES = "read:konobangu write:konobangu" +# OIDC_EXTRA_CLAIM_KEY = "" +# OIDC_EXTRA_CLAIM_VALUE = "" +MIKAN_PROXY = "http://127.0.0.1:8899" +# MIKAN_PROXY_AUTH_HEADER = "" +# MIKAN_NO_PROXY = "" +MIKAN_PROXY_ACCEPT_INVALID_CERTS = true diff --git a/apps/recorder/Cargo.toml b/apps/recorder/Cargo.toml index e890dd0..38ff377 100644 --- a/apps/recorder/Cargo.toml +++ b/apps/recorder/Cargo.toml @@ -111,7 +111,12 @@ tracing-appender = "0.2.3" clap = "4.5.31" ipnetwork = "0.21.1" typed-builder = "0.21.0" -apalis = { version = "0.7", features = ["limit", "tracing", "catch-panic"] } +apalis = { version = "0.7", features = [ + "limit", + "tracing", + "catch-panic", + "retry", +] } apalis-sql = { version = "0.7", features = ["postgres"] } cocoon = { version = "0.4.3", features = ["getrandom", "thiserror"] } rand = "0.9.1" diff --git a/apps/recorder/src/extract/mikan/web.rs b/apps/recorder/src/extract/mikan/web.rs index f273be9..9c7d9e3 100644 --- a/apps/recorder/src/extract/mikan/web.rs +++ b/apps/recorder/src/extract/mikan/web.rs @@ -710,6 +710,7 @@ pub async fn scrape_mikan_bangumi_meta_from_bangumi_homepage_url( ) } +#[allow(dead_code)] #[instrument(err, skip_all, fields(mikan_bangumi_homepage_url = mikan_bangumi_homepage_url.as_str()))] pub async fn scrape_mikan_bangumi_index_meta_from_bangumi_homepage_url( mikan_client: &MikanClient, diff --git a/apps/recorder/src/task/service.rs b/apps/recorder/src/task/service.rs index 1ea2e37..a8234be 100644 --- a/apps/recorder/src/task/service.rs +++ b/apps/recorder/src/task/service.rs @@ -3,6 +3,7 @@ use std::{ops::Deref, sync::Arc}; use apalis::prelude::*; use apalis_sql::{ Config, + context::SqlContext, postgres::{PgListen, PostgresStorage}, }; use tokio::sync::RwLock; @@ -51,7 +52,13 @@ impl TaskService { ) -> RecorderResult { let task_id = { let mut storage = self.subscriber_task_storage.write().await; - storage.push(subscriber_task).await?.task_id + let sql_context = { + let mut c = SqlContext::default(); + c.set_max_attempts(1); + c + }; + let request = Request::new_with_ctx(subscriber_task, sql_context); + storage.push_request(request).await?.task_id }; Ok(task_id) diff --git a/apps/webui/.gitignore b/apps/webui/.gitignore index 6781085..59388b9 100644 --- a/apps/webui/.gitignore +++ b/apps/webui/.gitignore @@ -13,3 +13,4 @@ dist/ .idea .env.local .env.*.lcoal +.tanstack \ No newline at end of file diff --git a/apps/webui/src/components/ui/detail-empty-view.tsx b/apps/webui/src/components/ui/detail-empty-view.tsx index 66788d0..cfabf09 100644 --- a/apps/webui/src/components/ui/detail-empty-view.tsx +++ b/apps/webui/src/components/ui/detail-empty-view.tsx @@ -1,18 +1,30 @@ -import { memo } from "react"; +import { cn } from "@/presentation/utils"; +import { DetailedHTMLProps, HTMLAttributes, memo } from "react"; import { Card, CardContent } from "./card"; -export interface DetailEmptyViewProps { +export interface DetailEmptyViewProps + extends DetailedHTMLProps, HTMLDivElement> { message: string; + fullWidth?: boolean; } -export const DetailEmptyView = memo(({ message }: DetailEmptyViewProps) => { - return ( -
- - -

{message ?? "No data"}

-
-
-
- ); -}); +export const DetailEmptyView = memo( + ({ message, fullWidth, ...props }: DetailEmptyViewProps) => { + return ( +
+ + +

{message ?? "No data"}

+
+
+
+ ); + } +); diff --git a/apps/webui/src/infra/graphql/gql/graphql.ts b/apps/webui/src/infra/graphql/gql/graphql.ts index 816d952..3997a9f 100644 --- a/apps/webui/src/infra/graphql/gql/graphql.ts +++ b/apps/webui/src/infra/graphql/gql/graphql.ts @@ -133,7 +133,7 @@ export type BangumiInsertInput = { savePath?: InputMaybe; season: Scalars['Int']['input']; seasonRaw?: InputMaybe; - subscriberId: Scalars['Int']['input']; + subscriberId?: InputMaybe; updatedAt?: InputMaybe; }; @@ -267,7 +267,7 @@ export type Credential3rdInsertInput = { credentialType: Credential3rdTypeEnum; id?: InputMaybe; password?: InputMaybe; - subscriberId: Scalars['Int']['input']; + subscriberId?: InputMaybe; updatedAt?: InputMaybe; userAgent?: InputMaybe; username?: InputMaybe; @@ -450,7 +450,7 @@ export type DownloadersInsertInput = { id?: InputMaybe; password: Scalars['String']['input']; savePath: Scalars['String']['input']; - subscriberId: Scalars['Int']['input']; + subscriberId?: InputMaybe; updatedAt?: InputMaybe; username: Scalars['String']['input']; }; @@ -566,7 +566,7 @@ export type DownloadsInsertInput = { rawName: Scalars['String']['input']; savePath?: InputMaybe; status: DownloadStatusEnum; - subscriberId: Scalars['Int']['input']; + subscriberId?: InputMaybe; updatedAt?: InputMaybe; url: Scalars['String']['input']; }; @@ -729,7 +729,7 @@ export type EpisodesInsertInput = { season: Scalars['Int']['input']; seasonRaw?: InputMaybe; source?: InputMaybe; - subscriberId: Scalars['Int']['input']; + subscriberId?: InputMaybe; subtitle?: InputMaybe; updatedAt?: InputMaybe; }; @@ -1292,7 +1292,7 @@ export type SubscriberTasksInsertInput = { priority: Scalars['Int']['input']; runAt: Scalars['String']['input']; status: SubscriberTaskStatusEnum; - subscriberId: Scalars['Int']['input']; + subscriberId?: InputMaybe; taskType: SubscriberTaskTypeEnum; }; @@ -1449,7 +1449,7 @@ export type SubscriptionBangumiFilterInput = { export type SubscriptionBangumiInsertInput = { bangumiId: Scalars['Int']['input']; id?: InputMaybe; - subscriberId: Scalars['Int']['input']; + subscriberId?: InputMaybe; subscriptionId: Scalars['Int']['input']; }; @@ -1532,7 +1532,7 @@ export type SubscriptionEpisodeFilterInput = { export type SubscriptionEpisodeInsertInput = { episodeId: Scalars['Int']['input']; id?: InputMaybe; - subscriberId: Scalars['Int']['input']; + subscriberId?: InputMaybe; subscriptionId: Scalars['Int']['input']; }; @@ -1645,7 +1645,7 @@ export type SubscriptionsInsertInput = { enabled: Scalars['Boolean']['input']; id?: InputMaybe; sourceUrl: Scalars['String']['input']; - subscriberId: Scalars['Int']['input']; + subscriberId?: InputMaybe; updatedAt?: InputMaybe; }; diff --git a/apps/webui/src/presentation/routes/_app/tasks/manage.tsx b/apps/webui/src/presentation/routes/_app/tasks/manage.tsx index 78e40f4..20a1c6d 100644 --- a/apps/webui/src/presentation/routes/_app/tasks/manage.tsx +++ b/apps/webui/src/presentation/routes/_app/tasks/manage.tsx @@ -231,7 +231,7 @@ function TaskManageRouteComponent() { ); }) ) : ( - + )} diff --git a/justfile b/justfile index 513bd65..8d4bc97 100644 --- a/justfile +++ b/justfile @@ -2,8 +2,9 @@ set windows-shell := ["pwsh.exe", "-c"] set dotenv-load := true prepare-dev: - cargo install sea-orm-cli cargo-llvm-cov cargo-nextest - # install watchexec + cargo install cargo-binstall + cargo binstall sea-orm-cli cargo-llvm-cov cargo-nextest + # install watchexec just zellij prepare-dev-testcontainers: docker pull linuxserver/qbittorrent:latest @@ -14,7 +15,7 @@ dev-webui: pnpm run --filter=webui dev dev-proxy: - npx --yes kill-port --port 8899,5010 + npx --yes kill-port --port 8899,5005 pnpm run --parallel --filter=proxy dev dev-recorder: diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 98c104e..e91e0d9 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -1,13 +1,13 @@ packages: - - packages/* - - apps/* - - '!packages/testing-torrents' + - packages/* + - apps/* + - "!packages/testing-torrents" onlyBuiltDependencies: - - '@biomejs/biome' - - '@parcel/watcher' - - '@tailwindcss/oxide' - - bufferutil - - core-js - - esbuild - - sharp - - utf-8-validate + - "@biomejs/biome" + - "@parcel/watcher" + - "@tailwindcss/oxide" + - bufferutil + - core-js + - esbuild + - sharp + - utf-8-validate