mirror of
https://github.com/kikootwo/ReadMeABook.git
synced 2026-06-03 12:50:09 +00:00
Merge branch 'main' of https://github.com/kikootwo/ReadMeABook
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
import axios from 'axios';
|
||||
import { XMLParser } from 'fast-xml-parser';
|
||||
import { prisma } from '@/lib/db';
|
||||
import { Prisma } from '@/generated/prisma/client';
|
||||
import { RMABLogger } from '@/lib/utils/logger';
|
||||
import {
|
||||
ShelfBook,
|
||||
@@ -118,7 +119,10 @@ export async function processGoodreadsShelves(
|
||||
const stats = createEmptyStats();
|
||||
const maxLookups = resolveMaxLookups(options);
|
||||
|
||||
const whereClause = options.shelfId ? { id: options.shelfId } : {};
|
||||
const whereClause: Prisma.GoodreadsShelfWhereInput = {};
|
||||
if (options.shelfId) whereClause.id = options.shelfId;
|
||||
if (options.userId) whereClause.userId = options.userId;
|
||||
|
||||
const shelves = await prisma.goodreadsShelf.findMany({
|
||||
where: whereClause,
|
||||
include: { user: { select: { id: true, plexUsername: true } } },
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
import { prisma } from '@/lib/db';
|
||||
import { Prisma } from '@/generated/prisma/client';
|
||||
import { getEncryptionService } from '@/lib/services/encryption.service';
|
||||
import { RMABLogger } from '@/lib/utils/logger';
|
||||
import { fetchHardcoverList, HardcoverApiBook } from '@/lib/services/hardcover-api.service';
|
||||
@@ -38,8 +39,10 @@ export async function processHardcoverShelves(
|
||||
const log = jobLogger || logger;
|
||||
const stats = createEmptyStats();
|
||||
const maxLookups = resolveMaxLookups(options);
|
||||
const whereClause: Prisma.HardcoverShelfWhereInput = {};
|
||||
if (options.shelfId) whereClause.id = options.shelfId;
|
||||
if (options.userId) whereClause.userId = options.userId;
|
||||
|
||||
const whereClause = options.shelfId ? { id: options.shelfId } : {};
|
||||
const shelves = await prisma.hardcoverShelf.findMany({
|
||||
where: whereClause,
|
||||
include: { user: { select: { id: true, plexUsername: true } } },
|
||||
|
||||
@@ -112,6 +112,7 @@ export interface SyncShelvesPayload extends JobPayload {
|
||||
scheduledJobId?: string;
|
||||
shelfId?: string;
|
||||
shelfType?: 'goodreads' | 'hardcover';
|
||||
userId?: string;
|
||||
maxLookupsPerShelf?: number;
|
||||
}
|
||||
|
||||
@@ -770,7 +771,13 @@ export class JobQueueService {
|
||||
/**
|
||||
* Add sync reading shelves job
|
||||
*/
|
||||
async addSyncShelvesJob(scheduledJobId?: string, shelfId?: string, shelfType?: 'goodreads' | 'hardcover', maxLookupsPerShelf?: number): Promise<string> {
|
||||
async addSyncShelvesJob(
|
||||
scheduledJobId?: string,
|
||||
shelfId?: string,
|
||||
shelfType?: 'goodreads' | 'hardcover',
|
||||
maxLookupsPerShelf?: number,
|
||||
userId?: string
|
||||
): Promise<string> {
|
||||
return await this.addJob(
|
||||
'sync_reading_shelves',
|
||||
{
|
||||
@@ -778,6 +785,7 @@ export class JobQueueService {
|
||||
shelfId,
|
||||
shelfType,
|
||||
maxLookupsPerShelf,
|
||||
userId,
|
||||
} as SyncShelvesPayload,
|
||||
{
|
||||
priority: 7,
|
||||
|
||||
@@ -39,6 +39,7 @@ export interface ShelfSyncStats {
|
||||
/** Common sync options */
|
||||
export interface ShelfSyncOptions {
|
||||
shelfId?: string;
|
||||
userId?: string;
|
||||
maxLookupsPerShelf?: number;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user