fix(books): add missing book metadata fields (#1032)
This commit is contained in:
@@ -28,16 +28,37 @@ public class AppBookSummary {
|
|||||||
private Instant addedOn;
|
private Instant addedOn;
|
||||||
private Instant lastReadTime;
|
private Instant lastReadTime;
|
||||||
private Float readProgress;
|
private Float readProgress;
|
||||||
|
private Long primaryFileId;
|
||||||
private String primaryFileType;
|
private String primaryFileType;
|
||||||
|
private String primaryFileName;
|
||||||
private Instant coverUpdatedOn;
|
private Instant coverUpdatedOn;
|
||||||
private Instant audiobookCoverUpdatedOn;
|
private Instant audiobookCoverUpdatedOn;
|
||||||
private Boolean isPhysical;
|
private Boolean isPhysical;
|
||||||
|
|
||||||
// Metadata for filtering
|
// Metadata for filtering
|
||||||
|
private String publisher;
|
||||||
|
private List<String> categories;
|
||||||
|
private List<String> tags;
|
||||||
|
private List<String> moods;
|
||||||
|
private String language;
|
||||||
|
private String narrator;
|
||||||
|
private String isbn13;
|
||||||
|
private String isbn10;
|
||||||
private LocalDate publishedDate;
|
private LocalDate publishedDate;
|
||||||
private Integer pageCount;
|
private Integer pageCount;
|
||||||
private Integer ageRating;
|
private Integer ageRating;
|
||||||
private String contentRating;
|
private String contentRating;
|
||||||
private Float metadataMatchScore;
|
private Float metadataMatchScore;
|
||||||
private Long fileSizeKb;
|
private Long fileSizeKb;
|
||||||
|
private Double amazonRating;
|
||||||
|
private Integer amazonReviewCount;
|
||||||
|
private Double goodreadsRating;
|
||||||
|
private Integer goodreadsReviewCount;
|
||||||
|
private Double hardcoverRating;
|
||||||
|
private Integer hardcoverReviewCount;
|
||||||
|
private Double ranobedbRating;
|
||||||
|
private Double lubimyczytacRating;
|
||||||
|
private Double audibleRating;
|
||||||
|
private Integer audibleReviewCount;
|
||||||
|
private Boolean allMetadataLocked;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,16 +31,37 @@ public interface AppBookMapper {
|
|||||||
@Mapping(target = "addedOn", source = "book.addedOn")
|
@Mapping(target = "addedOn", source = "book.addedOn")
|
||||||
@Mapping(target = "lastReadTime", source = "progress.lastReadTime")
|
@Mapping(target = "lastReadTime", source = "progress.lastReadTime")
|
||||||
@Mapping(target = "readProgress", source = "progress", qualifiedByName = "mapReadProgress")
|
@Mapping(target = "readProgress", source = "progress", qualifiedByName = "mapReadProgress")
|
||||||
|
@Mapping(target = "primaryFileId", source = "book", qualifiedByName = "mapPrimaryFileId")
|
||||||
@Mapping(target = "primaryFileType", source = "book", qualifiedByName = "mapPrimaryFileType")
|
@Mapping(target = "primaryFileType", source = "book", qualifiedByName = "mapPrimaryFileType")
|
||||||
|
@Mapping(target = "primaryFileName", source = "book", qualifiedByName = "mapPrimaryFileName")
|
||||||
@Mapping(target = "coverUpdatedOn", source = "book.metadata.coverUpdatedOn")
|
@Mapping(target = "coverUpdatedOn", source = "book.metadata.coverUpdatedOn")
|
||||||
@Mapping(target = "audiobookCoverUpdatedOn", source = "book.metadata.audiobookCoverUpdatedOn")
|
@Mapping(target = "audiobookCoverUpdatedOn", source = "book.metadata.audiobookCoverUpdatedOn")
|
||||||
@Mapping(target = "isPhysical", source = "book.isPhysical")
|
@Mapping(target = "isPhysical", source = "book.isPhysical")
|
||||||
|
@Mapping(target = "publisher", source = "book.metadata.publisher")
|
||||||
|
@Mapping(target = "categories", source = "book.metadata.categories", qualifiedByName = "mapCategoryNames")
|
||||||
|
@Mapping(target = "tags", source = "book.metadata.tags", qualifiedByName = "mapTagNames")
|
||||||
|
@Mapping(target = "moods", source = "book.metadata.moods", qualifiedByName = "mapMoodNames")
|
||||||
|
@Mapping(target = "language", source = "book.metadata.language")
|
||||||
|
@Mapping(target = "narrator", source = "book.metadata.narrator")
|
||||||
|
@Mapping(target = "isbn13", source = "book.metadata.isbn13")
|
||||||
|
@Mapping(target = "isbn10", source = "book.metadata.isbn10")
|
||||||
@Mapping(target = "publishedDate", source = "book.metadata.publishedDate")
|
@Mapping(target = "publishedDate", source = "book.metadata.publishedDate")
|
||||||
@Mapping(target = "pageCount", source = "book.metadata.pageCount")
|
@Mapping(target = "pageCount", source = "book.metadata.pageCount")
|
||||||
@Mapping(target = "ageRating", source = "book.metadata.ageRating")
|
@Mapping(target = "ageRating", source = "book.metadata.ageRating")
|
||||||
@Mapping(target = "contentRating", source = "book.metadata.contentRating")
|
@Mapping(target = "contentRating", source = "book.metadata.contentRating")
|
||||||
@Mapping(target = "metadataMatchScore", source = "book.metadataMatchScore")
|
@Mapping(target = "metadataMatchScore", source = "book.metadataMatchScore")
|
||||||
@Mapping(target = "fileSizeKb", source = "book", qualifiedByName = "mapFileSizeKb")
|
@Mapping(target = "fileSizeKb", source = "book", qualifiedByName = "mapFileSizeKb")
|
||||||
|
@Mapping(target = "amazonRating", source = "book.metadata.amazonRating")
|
||||||
|
@Mapping(target = "amazonReviewCount", source = "book.metadata.amazonReviewCount")
|
||||||
|
@Mapping(target = "goodreadsRating", source = "book.metadata.goodreadsRating")
|
||||||
|
@Mapping(target = "goodreadsReviewCount", source = "book.metadata.goodreadsReviewCount")
|
||||||
|
@Mapping(target = "hardcoverRating", source = "book.metadata.hardcoverRating")
|
||||||
|
@Mapping(target = "hardcoverReviewCount", source = "book.metadata.hardcoverReviewCount")
|
||||||
|
@Mapping(target = "ranobedbRating", source = "book.metadata.ranobedbRating")
|
||||||
|
@Mapping(target = "lubimyczytacRating", source = "book.metadata.lubimyczytacRating")
|
||||||
|
@Mapping(target = "audibleRating", source = "book.metadata.audibleRating")
|
||||||
|
@Mapping(target = "audibleReviewCount", source = "book.metadata.audibleReviewCount")
|
||||||
|
@Mapping(target = "allMetadataLocked", source = "book.metadata", qualifiedByName = "mapAllMetadataLocked")
|
||||||
AppBookSummary toSummary(BookEntity book, UserBookProgressEntity progress);
|
AppBookSummary toSummary(BookEntity book, UserBookProgressEntity progress);
|
||||||
|
|
||||||
@Mapping(target = "id", source = "book.id")
|
@Mapping(target = "id", source = "book.id")
|
||||||
@@ -114,6 +135,39 @@ public interface AppBookMapper {
|
|||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Named("mapCategoryNames")
|
||||||
|
default List<String> mapCategoryNames(Set<CategoryEntity> categories) {
|
||||||
|
if (categories == null || categories.isEmpty()) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
return categories.stream()
|
||||||
|
.map(CategoryEntity::getName)
|
||||||
|
.sorted()
|
||||||
|
.toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Named("mapTagNames")
|
||||||
|
default List<String> mapTagNames(Set<TagEntity> tags) {
|
||||||
|
if (tags == null || tags.isEmpty()) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
return tags.stream()
|
||||||
|
.map(TagEntity::getName)
|
||||||
|
.sorted()
|
||||||
|
.toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Named("mapMoodNames")
|
||||||
|
default List<String> mapMoodNames(Set<MoodEntity> moods) {
|
||||||
|
if (moods == null || moods.isEmpty()) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
return moods.stream()
|
||||||
|
.map(MoodEntity::getName)
|
||||||
|
.sorted()
|
||||||
|
.toList();
|
||||||
|
}
|
||||||
|
|
||||||
@Named("mapThumbnailUrl")
|
@Named("mapThumbnailUrl")
|
||||||
default String mapThumbnailUrl(BookEntity book) {
|
default String mapThumbnailUrl(BookEntity book) {
|
||||||
if (book == null || book.getId() == null) {
|
if (book == null || book.getId() == null) {
|
||||||
@@ -129,6 +183,11 @@ public interface AppBookMapper {
|
|||||||
return primaryFile != null ? primaryFile.getFileSizeKb() : null;
|
return primaryFile != null ? primaryFile.getFileSizeKb() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Named("mapAllMetadataLocked")
|
||||||
|
default Boolean mapAllMetadataLocked(BookMetadataEntity metadata) {
|
||||||
|
return metadata != null && metadata.areAllFieldsLocked();
|
||||||
|
}
|
||||||
|
|
||||||
@Named("mapShelves")
|
@Named("mapShelves")
|
||||||
default List<AppShelfSummary> mapShelves(Set<ShelfEntity> shelves) {
|
default List<AppShelfSummary> mapShelves(Set<ShelfEntity> shelves) {
|
||||||
if (shelves == null || shelves.isEmpty()) {
|
if (shelves == null || shelves.isEmpty()) {
|
||||||
@@ -271,6 +330,24 @@ public interface AppBookMapper {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Named("mapPrimaryFileId")
|
||||||
|
default Long mapPrimaryFileId(BookEntity book) {
|
||||||
|
if (book == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
BookFileEntity primaryFile = book.getPrimaryBookFile();
|
||||||
|
return primaryFile != null ? primaryFile.getId() : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Named("mapPrimaryFileName")
|
||||||
|
default String mapPrimaryFileName(BookEntity book) {
|
||||||
|
if (book == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
BookFileEntity primaryFile = book.getPrimaryBookFile();
|
||||||
|
return primaryFile != null ? primaryFile.getFileName() : null;
|
||||||
|
}
|
||||||
|
|
||||||
@Named("mapFileTypes")
|
@Named("mapFileTypes")
|
||||||
default List<String> mapFileTypes(BookEntity book) {
|
default List<String> mapFileTypes(BookEntity book) {
|
||||||
if (book == null || book.getBookFiles() == null || book.getBookFiles().isEmpty()) {
|
if (book == null || book.getBookFiles() == null || book.getBookFiles().isEmpty()) {
|
||||||
|
|||||||
@@ -246,6 +246,9 @@ export class BookBrowserComponent implements AfterViewInit {
|
|||||||
case 'amazonRating': scopeFilters.amazonRating = strValues; break;
|
case 'amazonRating': scopeFilters.amazonRating = strValues; break;
|
||||||
case 'goodreadsRating': scopeFilters.goodreadsRating = strValues; break;
|
case 'goodreadsRating': scopeFilters.goodreadsRating = strValues; break;
|
||||||
case 'hardcoverRating': scopeFilters.hardcoverRating = 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 'pageCount': scopeFilters.pageCount = strValues; break;
|
||||||
case 'shelfStatus':
|
case 'shelfStatus':
|
||||||
scopeFilters.shelfStatus = strValues;
|
scopeFilters.shelfStatus = strValues;
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import {BookType} from './book.model';
|
||||||
|
|
||||||
export interface AppPageResponse<T> {
|
export interface AppPageResponse<T> {
|
||||||
content: T[];
|
content: T[];
|
||||||
page: number;
|
page: number;
|
||||||
@@ -21,16 +23,37 @@ export interface AppBookSummary {
|
|||||||
addedOn: string | null;
|
addedOn: string | null;
|
||||||
lastReadTime: string | null;
|
lastReadTime: string | null;
|
||||||
readProgress: number | null;
|
readProgress: number | null;
|
||||||
primaryFileType: string | null;
|
primaryFileId: number | null;
|
||||||
|
primaryFileType: BookType | null;
|
||||||
|
primaryFileName: string | null;
|
||||||
coverUpdatedOn: string | null;
|
coverUpdatedOn: string | null;
|
||||||
audiobookCoverUpdatedOn: string | null;
|
audiobookCoverUpdatedOn: string | null;
|
||||||
isPhysical: boolean | 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;
|
publishedDate: string | null;
|
||||||
pageCount: number | null;
|
pageCount: number | null;
|
||||||
ageRating: number | null;
|
ageRating: number | null;
|
||||||
contentRating: string | null;
|
contentRating: string | null;
|
||||||
metadataMatchScore: number | null;
|
metadataMatchScore: number | null;
|
||||||
fileSizeKb: 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 {
|
export interface AppFilterOptions {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import {
|
|||||||
AppFilterOptions,
|
AppFilterOptions,
|
||||||
AppPageResponse,
|
AppPageResponse,
|
||||||
} from '../model/app-book.model';
|
} 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;
|
const PAGE_SIZE = 50;
|
||||||
|
|
||||||
@@ -62,16 +62,6 @@ export class AppBooksApiService {
|
|||||||
const data = this.booksQuery.data();
|
const data = this.booksQuery.data();
|
||||||
if (!data) return [];
|
if (!data) return [];
|
||||||
return data.pages.flatMap(page => page.content.map(summaryToBook));
|
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(() => {
|
readonly totalElements = computed(() => {
|
||||||
@@ -249,18 +239,35 @@ function summaryToBook(summary: AppBookSummary): Book {
|
|||||||
bookId: summary.id,
|
bookId: summary.id,
|
||||||
title: summary.title,
|
title: summary.title,
|
||||||
authors: summary.authors ?? [],
|
authors: summary.authors ?? [],
|
||||||
|
publisher: summary.publisher ?? undefined,
|
||||||
seriesName: summary.seriesName,
|
seriesName: summary.seriesName,
|
||||||
seriesNumber: summary.seriesNumber,
|
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,
|
coverUpdatedOn: summary.coverUpdatedOn,
|
||||||
audiobookCoverUpdatedOn: summary.audiobookCoverUpdatedOn,
|
audiobookCoverUpdatedOn: summary.audiobookCoverUpdatedOn,
|
||||||
publishedDate: summary.publishedDate ?? undefined,
|
publishedDate: summary.publishedDate ?? undefined,
|
||||||
pageCount: summary.pageCount,
|
pageCount: summary.pageCount,
|
||||||
ageRating: summary.ageRating,
|
ageRating: summary.ageRating,
|
||||||
contentRating: summary.contentRating,
|
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
|
primaryFile: summaryToPrimaryFile(summary),
|
||||||
? {bookType: summary.primaryFileType as BookType, extension: summary.primaryFileType.toLowerCase()}
|
|
||||||
: null,
|
|
||||||
pdfProgress: summary.readProgress != null
|
pdfProgress: summary.readProgress != null
|
||||||
? {page: 0, percentage: summary.readProgress}
|
? {page: 0, percentage: summary.readProgress}
|
||||||
: null,
|
: null,
|
||||||
@@ -269,3 +276,33 @@ function summaryToBook(summary: AppBookSummary): Book {
|
|||||||
shelves: [],
|
shelves: [],
|
||||||
} as unknown as Book;
|
} 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