fix(dashboard): address rail review feedback

This commit is contained in:
4gray committed 2026-06-20 23:10:18 +02:00
1 parent b6c5367d63
commit dbc90bed06
4 files changed
+22 -14

No files matched your search

@@ -23,6 +23,9 @@ function createGlobalFavoritesDbMock(rows: unknown[]) {
innerJoin: jest.fn(),
limit: jest.fn(),
orderBy: jest.fn(),
then: jest.fn((resolve, reject) =>
Promise.resolve(rows).then(resolve, reject)
),
where: whereMock,
};
query.from.mockReturnValue(query);
@@ -48,7 +51,7 @@ describe('favorites.operations', () => {
});
it('filters live global favorites after scanning the small favorites set', async () => {
const { db } = createGlobalFavoritesDbMock([
const { db, query } = createGlobalFavoritesDbMock([
{
id: 1,
title: 'Saved Movie',
@@ -64,6 +67,7 @@ describe('favorites.operations', () => {
const result = await getGlobalFavorites(db);
expect(whereMock).not.toHaveBeenCalled();
expect(query.limit).not.toHaveBeenCalled();
expect(result).toEqual([
expect.objectContaining({
id: 2,
@@ -10,7 +10,6 @@ import {
import { persistContentBackdropIfMissing } from './content-backdrop.operations';
const DEFAULT_BATCH_SIZE = 100;
const GLOBAL_LIVE_FAVORITES_SCAN_LIMIT = 2000;
export async function addFavorite(
db: AppDatabase,
@@ -92,7 +91,7 @@ export async function getFavorites(db: AppDatabase, playlistId: string) {
export async function getGlobalFavorites(db: AppDatabase) {
const favorites = await selectGlobalFavoriteRows(db, {
includeBackdrop: false,
}).limit(GLOBAL_LIVE_FAVORITES_SCAN_LIMIT);
});
return favorites.filter((favorite) => favorite.type === 'live').slice(0, 300);
}