mirror of
https://github.com/kikootwo/ReadMeABook.git
synced 2026-06-02 20:30:10 +00:00
Add first-class ebook request support and UI
Implements first-class ebook requests with their own type, parent-child relationship to audiobook requests, and separate status flow. Updates database schema and migrations to support 'type' and 'parentRequestId' fields on requests. Adds processors and job types for ebook search and direct HTTP download from Anna's Archive, with FlareSolverr integration for Cloudflare bypass. Enhances admin UI tables and request actions to display and manage ebook requests, including orange badge and source links. Updates documentation to reflect new ebook support, configuration, and behavior.
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "requests" ADD COLUMN IF NOT EXISTS "type" TEXT NOT NULL DEFAULT 'audiobook';
|
||||
ALTER TABLE "requests" ADD COLUMN IF NOT EXISTS "parent_request_id" TEXT;
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX IF NOT EXISTS "requests_type_idx" ON "requests"("type");
|
||||
CREATE INDEX IF NOT EXISTS "requests_parent_request_id_idx" ON "requests"("parent_request_id");
|
||||
|
||||
-- AddForeignKey (with ON DELETE SET NULL)
|
||||
DO $$
|
||||
BEGIN
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM pg_constraint
|
||||
WHERE conname = 'requests_parent_request_id_fkey'
|
||||
) THEN
|
||||
ALTER TABLE "requests" ADD CONSTRAINT "requests_parent_request_id_fkey"
|
||||
FOREIGN KEY ("parent_request_id") REFERENCES "requests"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
END IF;
|
||||
END $$;
|
||||
+13
-2
@@ -212,7 +212,8 @@ model Request {
|
||||
audiobookId String @map("audiobook_id")
|
||||
status String @default("pending")
|
||||
// Status values: pending, awaiting_approval, denied, searching, downloading, processing, downloaded, available, failed, cancelled, awaiting_search, awaiting_import, warn
|
||||
// Flow: pending → searching → downloading → processing → downloaded → available (when matched in Plex)
|
||||
// Flow (audiobook): pending → searching → downloading → processing → downloaded → available (when matched in Plex)
|
||||
// Flow (ebook): pending → searching → downloading → processing → downloaded (terminal - no available state)
|
||||
progress Int @default(0) // 0-100
|
||||
priority Int @default(0)
|
||||
errorMessage String? @map("error_message") @db.Text
|
||||
@@ -227,6 +228,11 @@ model Request {
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
completedAt DateTime? @map("completed_at")
|
||||
|
||||
// Request type: 'audiobook' (default) or 'ebook'
|
||||
// Ebook requests are created automatically when an audiobook is organized (if ebook downloads enabled)
|
||||
type String @default("audiobook") // 'audiobook' | 'ebook'
|
||||
parentRequestId String? @map("parent_request_id") // Links ebook request to originating audiobook request
|
||||
|
||||
// Soft delete support
|
||||
deletedAt DateTime? @map("deleted_at")
|
||||
deletedBy String? @map("deleted_by") // Admin user ID
|
||||
@@ -236,12 +242,16 @@ model Request {
|
||||
audiobook Audiobook @relation(fields: [audiobookId], references: [id], onDelete: Cascade)
|
||||
downloadHistory DownloadHistory[]
|
||||
jobs Job[]
|
||||
parentRequest Request? @relation("EbookParent", fields: [parentRequestId], references: [id], onDelete: SetNull)
|
||||
childRequests Request[] @relation("EbookParent")
|
||||
|
||||
@@index([userId])
|
||||
@@index([audiobookId])
|
||||
@@index([status])
|
||||
@@index([createdAt(sort: Desc)])
|
||||
@@index([deletedAt])
|
||||
@@index([type])
|
||||
@@index([parentRequestId])
|
||||
@@map("requests")
|
||||
}
|
||||
|
||||
@@ -260,7 +270,7 @@ model DownloadHistory {
|
||||
leechers Int?
|
||||
qualityScore Int? @map("quality_score")
|
||||
selected Boolean @default(false)
|
||||
downloadClient String? @map("download_client") // qbittorrent, sabnzbd
|
||||
downloadClient String? @map("download_client") // qbittorrent, sabnzbd, direct (HTTP download for ebooks)
|
||||
downloadClientId String? @map("download_client_id")
|
||||
downloadStatus String? @map("download_status")
|
||||
// Status values: queued, downloading, completed, failed, stalled
|
||||
@@ -302,6 +312,7 @@ model Job {
|
||||
requestId String? @map("request_id")
|
||||
type String
|
||||
// Job types: search_indexers, monitor_download, organize_files, scan_plex, plex_recently_added_check, match_plex
|
||||
// Ebook job types: search_ebook, start_direct_download, monitor_direct_download
|
||||
status String @default("pending")
|
||||
// Status values: pending, active, completed, failed, delayed, stuck
|
||||
priority Int @default(0)
|
||||
|
||||
Reference in New Issue
Block a user