fix(books): add missing book metadata fields (#1032)
This commit is contained in:
@@ -246,6 +246,9 @@ export class BookBrowserComponent implements AfterViewInit {
|
||||
case 'amazonRating': scopeFilters.amazonRating = strValues; break;
|
||||
case 'goodreadsRating': scopeFilters.goodreadsRating = strValues; break;
|
||||
case 'hardcoverRating': scopeFilters.hardcoverRating = strValues; break;
|
||||
case 'lubimyczytacRating': scopeFilters.lubimyczytacRating = strValues; break;
|
||||
case 'ranobedbRating': scopeFilters.ranobedbRating = strValues; break;
|
||||
case 'audibleRating': scopeFilters.audibleRating = strValues; break;
|
||||
case 'pageCount': scopeFilters.pageCount = strValues; break;
|
||||
case 'shelfStatus':
|
||||
scopeFilters.shelfStatus = strValues;
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import {BookType} from './book.model';
|
||||
|
||||
export interface AppPageResponse<T> {
|
||||
content: T[];
|
||||
page: number;
|
||||
@@ -21,16 +23,37 @@ export interface AppBookSummary {
|
||||
addedOn: string | null;
|
||||
lastReadTime: string | null;
|
||||
readProgress: number | null;
|
||||
primaryFileType: string | null;
|
||||
primaryFileId: number | null;
|
||||
primaryFileType: BookType | null;
|
||||
primaryFileName: string | null;
|
||||
coverUpdatedOn: string | null;
|
||||
audiobookCoverUpdatedOn: string | null;
|
||||
isPhysical: boolean | null;
|
||||
publisher: string | null;
|
||||
categories: string[] | null;
|
||||
tags: string[] | null;
|
||||
moods: string[] | null;
|
||||
language: string | null;
|
||||
narrator: string | null;
|
||||
isbn13: string | null;
|
||||
isbn10: string | null;
|
||||
publishedDate: string | null;
|
||||
pageCount: number | null;
|
||||
ageRating: number | null;
|
||||
contentRating: string | null;
|
||||
metadataMatchScore: number | null;
|
||||
fileSizeKb: number | null;
|
||||
amazonRating: number | null;
|
||||
amazonReviewCount: number | null;
|
||||
goodreadsRating: number | null;
|
||||
goodreadsReviewCount: number | null;
|
||||
hardcoverRating: number | null;
|
||||
hardcoverReviewCount: number | null;
|
||||
ranobedbRating: number | null;
|
||||
lubimyczytacRating: number | null;
|
||||
audibleRating: number | null;
|
||||
audibleReviewCount: number | null;
|
||||
allMetadataLocked: boolean | null;
|
||||
}
|
||||
|
||||
export interface AppFilterOptions {
|
||||
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
AppFilterOptions,
|
||||
AppPageResponse,
|
||||
} from '../model/app-book.model';
|
||||
import {Book, BookType, ReadStatus} from '../model/book.model';
|
||||
import {Book, BookFile, BookType, ReadStatus} from '../model/book.model';
|
||||
|
||||
const PAGE_SIZE = 50;
|
||||
|
||||
@@ -62,16 +62,6 @@ export class AppBooksApiService {
|
||||
const data = this.booksQuery.data();
|
||||
if (!data) return [];
|
||||
return data.pages.flatMap(page => page.content.map(summaryToBook));
|
||||
}, {
|
||||
equal: (a, b) => {
|
||||
if (a.length !== b.length) return false;
|
||||
for (let i = 0; i < a.length; i++) {
|
||||
if (a[i].id !== b[i].id) return false;
|
||||
if (a[i].metadata?.coverUpdatedOn !== b[i].metadata?.coverUpdatedOn) return false;
|
||||
if (a[i].metadata?.audiobookCoverUpdatedOn !== b[i].metadata?.audiobookCoverUpdatedOn) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
readonly totalElements = computed(() => {
|
||||
@@ -249,18 +239,35 @@ function summaryToBook(summary: AppBookSummary): Book {
|
||||
bookId: summary.id,
|
||||
title: summary.title,
|
||||
authors: summary.authors ?? [],
|
||||
publisher: summary.publisher ?? undefined,
|
||||
seriesName: summary.seriesName,
|
||||
seriesNumber: summary.seriesNumber,
|
||||
categories: summary.categories ?? [],
|
||||
tags: summary.tags ?? [],
|
||||
moods: summary.moods ?? [],
|
||||
language: summary.language ?? undefined,
|
||||
narrator: summary.narrator ?? undefined,
|
||||
isbn13: summary.isbn13 ?? undefined,
|
||||
isbn10: summary.isbn10 ?? undefined,
|
||||
coverUpdatedOn: summary.coverUpdatedOn,
|
||||
audiobookCoverUpdatedOn: summary.audiobookCoverUpdatedOn,
|
||||
publishedDate: summary.publishedDate ?? undefined,
|
||||
pageCount: summary.pageCount,
|
||||
ageRating: summary.ageRating,
|
||||
contentRating: summary.contentRating,
|
||||
amazonRating: summary.amazonRating,
|
||||
amazonReviewCount: summary.amazonReviewCount,
|
||||
goodreadsRating: summary.goodreadsRating,
|
||||
goodreadsReviewCount: summary.goodreadsReviewCount,
|
||||
hardcoverRating: summary.hardcoverRating,
|
||||
hardcoverReviewCount: summary.hardcoverReviewCount,
|
||||
ranobedbRating: summary.ranobedbRating,
|
||||
lubimyczytacRating: summary.lubimyczytacRating,
|
||||
audibleRating: summary.audibleRating,
|
||||
audibleReviewCount: summary.audibleReviewCount,
|
||||
allMetadataLocked: summary.allMetadataLocked ?? false,
|
||||
},
|
||||
primaryFile: summary.primaryFileType
|
||||
? {bookType: summary.primaryFileType as BookType, extension: summary.primaryFileType.toLowerCase()}
|
||||
: null,
|
||||
primaryFile: summaryToPrimaryFile(summary),
|
||||
pdfProgress: summary.readProgress != null
|
||||
? {page: 0, percentage: summary.readProgress}
|
||||
: null,
|
||||
@@ -269,3 +276,33 @@ function summaryToBook(summary: AppBookSummary): Book {
|
||||
shelves: [],
|
||||
} as unknown as Book;
|
||||
}
|
||||
|
||||
function summaryToPrimaryFile(summary: AppBookSummary): Partial<BookFile> | null {
|
||||
if (!summary.primaryFileType) return null;
|
||||
|
||||
const primaryFile: Partial<BookFile> = {
|
||||
bookId: summary.id,
|
||||
bookType: summary.primaryFileType,
|
||||
extension: summaryToPrimaryFileExtension(summary, summary.primaryFileType),
|
||||
fileSizeKb: summary.fileSizeKb ?? undefined,
|
||||
fileName: summary.primaryFileName ?? undefined,
|
||||
};
|
||||
|
||||
if (summary.primaryFileId != null) {
|
||||
primaryFile.id = summary.primaryFileId;
|
||||
}
|
||||
|
||||
return primaryFile;
|
||||
}
|
||||
|
||||
function summaryToPrimaryFileExtension(summary: AppBookSummary, bookType: BookType): string | undefined {
|
||||
const fileName = summary.primaryFileName;
|
||||
if (fileName) {
|
||||
const dotIndex = fileName.lastIndexOf('.');
|
||||
if (dotIndex >= 0 && dotIndex < fileName.length - 1) {
|
||||
return fileName.slice(dotIndex + 1).toLowerCase();
|
||||
}
|
||||
}
|
||||
|
||||
return bookType.toLowerCase();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user