From 34840a4961799e5c51c2be816956d97b1eaaa870 Mon Sep 17 00:00:00 2001 From: Andrew Polk Date: Thu, 24 Oct 2024 15:18:46 -0700 Subject: [PATCH] Grid: distinguish between read starts and finishes (BL-13994) --- src/components/Grid/GridColumns.tsx | 26 ++++++++++++++++---------- src/connection/LibraryQueryHooks.ts | 2 +- src/model/Book.ts | 1 + 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/components/Grid/GridColumns.tsx b/src/components/Grid/GridColumns.tsx index 3a29a0bc..1b8643f1 100644 --- a/src/components/Grid/GridColumns.tsx +++ b/src/components/Grid/GridColumns.tsx @@ -366,14 +366,21 @@ export function getBookGridColumnsDefinitions(): IGridColumn[] { defaultVisible: false, }, { - name: "analytics_finishedCount", - title: "Reads", + name: "readsStarted", + title: "Reads Started", + sortingEnabled: true, + getCellValue: (b: Book) => b.stats.startedCount, + defaultVisible: false, + }, + { + name: "reads", // historical name; keep for backward compatibility + title: "Reads Finished", sortingEnabled: true, getCellValue: (b: Book) => b.stats.finishedCount, defaultVisible: false, }, { - name: "analytics_shellDownloads", + name: "downloadsForTranslation", title: "Downloads for Translation", sortingEnabled: true, getCellValue: (b: Book) => b.stats.shellDownloads, @@ -381,20 +388,19 @@ export function getBookGridColumnsDefinitions(): IGridColumn[] { }, ]; - // generate the capitalized column names since the grid doesn't do that. return definitions - .sort((a, b) => { - // start off with title first. You can still customize by dragging - if (a.name === "title") return -1; - if (b.name === "title") return 1; - return a.name.localeCompare(b.name); - }) .map((c) => { const x = { ...c }; if (c.title === undefined) { x.title = titleCase(c.name); } return x; + }) + .sort((a, b) => { + // start off with title first. You can still customize by dragging + if (a.name === "title") return -1; + if (b.name === "title") return 1; + return a.title!.localeCompare(b.title!); }); } diff --git a/src/connection/LibraryQueryHooks.ts b/src/connection/LibraryQueryHooks.ts index c9951611..e3832e2f 100644 --- a/src/connection/LibraryQueryHooks.ts +++ b/src/connection/LibraryQueryHooks.ts @@ -394,7 +394,7 @@ export const gridBookKeys = "harvestLog,harvestStartedAt,tags,pageCount,phashOfFirstContentImage,show,credits,country," + "features,internetLimits,librarianNote,uploader,langPointers,importedBookSourceUrl," + "downloadCount,publisher,originalPublisher,brandingProjectName,keywords,edition,rebrand,leveledReaderLevel," + - "analytics_finishedCount,analytics_shellDownloads"; + "analytics_finishedCount,analytics_startedCount,analytics_shellDownloads"; export const gridBookIncludeFields = "uploader,langPointers"; diff --git a/src/model/Book.ts b/src/model/Book.ts index a0daa310..c0a0f2a6 100644 --- a/src/model/Book.ts +++ b/src/model/Book.ts @@ -24,6 +24,7 @@ export function createBookFromParseServerData(pojo: any): Book { b.allTitles = parseAllTitles(pojo.allTitles); b.originalTitle = pojo.originalTitle; b.languages = pojo.langPointers; + b.stats.startedCount = parseInt(pojo.analytics_startedCount, 10) || 0; b.stats.finishedCount = parseInt(pojo.analytics_finishedCount, 10) || 0; b.stats.shellDownloads = parseInt(pojo.analytics_shellDownloads, 10) || 0; b.finishCreationFromParseServerData(pojo.objectId);