feat: Add user ID parameter to shelf synchronization jobs and improve Prisma query type safety for shelf where clauses.

This commit is contained in:
Rob Walsh
2026-03-09 13:52:18 -06:00
parent c0cff56b47
commit 5d2e33e369
4 changed files with 13 additions and 4 deletions
+2
View File
@@ -2,6 +2,8 @@
* Component: Shelves Hook * Component: Shelves Hook
* Documentation: documentation/frontend/components.md * Documentation: documentation/frontend/components.md
*/ */
'use client';
import { useState } from 'react'; import { useState } from 'react';
import useSWR, { mutate } from 'swr'; import useSWR, { mutate } from 'swr';
import { useAuth } from '@/contexts/AuthContext'; import { useAuth } from '@/contexts/AuthContext';
+2 -1
View File
@@ -9,6 +9,7 @@
import axios from 'axios'; import axios from 'axios';
import { XMLParser } from 'fast-xml-parser'; import { XMLParser } from 'fast-xml-parser';
import { prisma } from '@/lib/db'; import { prisma } from '@/lib/db';
import { Prisma } from '@/generated/prisma/client';
import { RMABLogger } from '@/lib/utils/logger'; import { RMABLogger } from '@/lib/utils/logger';
import { import {
ShelfBook, ShelfBook,
@@ -118,7 +119,7 @@ export async function processGoodreadsShelves(
const stats = createEmptyStats(); const stats = createEmptyStats();
const maxLookups = resolveMaxLookups(options); const maxLookups = resolveMaxLookups(options);
const whereClause: any = {}; const whereClause: Prisma.GoodreadsShelfWhereInput = {};
if (options.shelfId) whereClause.id = options.shelfId; if (options.shelfId) whereClause.id = options.shelfId;
if (options.userId) whereClause.userId = options.userId; if (options.userId) whereClause.userId = options.userId;
+2 -2
View File
@@ -7,6 +7,7 @@
*/ */
import { prisma } from '@/lib/db'; import { prisma } from '@/lib/db';
import { Prisma } from '@/generated/prisma/client';
import { getEncryptionService } from '@/lib/services/encryption.service'; import { getEncryptionService } from '@/lib/services/encryption.service';
import { RMABLogger } from '@/lib/utils/logger'; import { RMABLogger } from '@/lib/utils/logger';
import { fetchHardcoverList, HardcoverApiBook } from '@/lib/services/hardcover-api.service'; import { fetchHardcoverList, HardcoverApiBook } from '@/lib/services/hardcover-api.service';
@@ -38,8 +39,7 @@ export async function processHardcoverShelves(
const log = jobLogger || logger; const log = jobLogger || logger;
const stats = createEmptyStats(); const stats = createEmptyStats();
const maxLookups = resolveMaxLookups(options); const maxLookups = resolveMaxLookups(options);
const whereClause: Prisma.HardcoverShelfWhereInput = {};
const whereClause: any = {};
if (options.shelfId) whereClause.id = options.shelfId; if (options.shelfId) whereClause.id = options.shelfId;
if (options.userId) whereClause.userId = options.userId; if (options.userId) whereClause.userId = options.userId;
+7 -1
View File
@@ -771,7 +771,13 @@ export class JobQueueService {
/** /**
* Add sync reading shelves job * 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( return await this.addJob(
'sync_reading_shelves', 'sync_reading_shelves',
{ {