mirror of
https://github.com/bookorbit/bookorbit.git
synced 2026-11-03 00:11:37 -06:00
fix(stats): use user ratings for neglected gems
This commit is contained in:
@@ -74,7 +74,7 @@ async function addToQueue() {
|
||||
</button>
|
||||
<div class="flex items-center gap-1 text-[11px] text-muted-foreground">
|
||||
<Star :size="12" class="fill-amber-400 text-amber-400" />
|
||||
<span>{{ (currentGem.rating / 2).toFixed(1) }}</span>
|
||||
<span>{{ currentGem.rating }}/5</span>
|
||||
<span>·</span>
|
||||
<span>{{ currentGem.waitingDays }}d waiting</span>
|
||||
</div>
|
||||
|
||||
@@ -25,6 +25,7 @@ import {
|
||||
genres,
|
||||
readingProgress,
|
||||
readingSessions,
|
||||
userBookRatings,
|
||||
userBookStatus,
|
||||
userReadingDailyStats,
|
||||
} from '../../db/schema';
|
||||
@@ -586,7 +587,7 @@ export class DashboardWidgetRepository {
|
||||
bookId: books.id,
|
||||
title: bookMetadata.title,
|
||||
coverSource: bookMetadata.coverSource,
|
||||
rating: bookMetadata.rating,
|
||||
rating: userBookRatings.rating,
|
||||
addedAt: books.addedAt,
|
||||
genre: sql<
|
||||
string | null
|
||||
@@ -594,12 +595,13 @@ export class DashboardWidgetRepository {
|
||||
})
|
||||
.from(books)
|
||||
.innerJoin(bookMetadata, eq(bookMetadata.bookId, books.id))
|
||||
.innerJoin(userBookRatings, and(eq(userBookRatings.bookId, books.id), eq(userBookRatings.userId, userId)))
|
||||
.leftJoin(booksAlreadyRead, eq(booksAlreadyRead.bookId, books.id))
|
||||
.where(
|
||||
and(
|
||||
inArray(books.libraryId, accessibleLibraryIds),
|
||||
eq(books.status, 'present'),
|
||||
gte(bookMetadata.rating, 8),
|
||||
gte(userBookRatings.rating, 4),
|
||||
isNull(booksAlreadyRead.bookId),
|
||||
),
|
||||
)
|
||||
|
||||
@@ -260,7 +260,7 @@ describe('DashboardWidgetService', () => {
|
||||
it('delegates to repo and returns result', async () => {
|
||||
const { service, widgetRepo, libraryService } = makeService();
|
||||
const mockData: NeglectedGemsWidgetData = {
|
||||
gems: [{ bookId: 1, title: 'Gem', hasCover: true, rating: 9, waitingDays: 100, genre: 'Fantasy' }],
|
||||
gems: [{ bookId: 1, title: 'Gem', hasCover: true, rating: 5, waitingDays: 100, genre: 'Fantasy' }],
|
||||
};
|
||||
libraryService.findAccessibleLibraryIds.mockResolvedValue([1]);
|
||||
widgetRepo.getNeglectedGems.mockResolvedValue(mockData);
|
||||
|
||||
Reference in New Issue
Block a user