Skip to content

Commit

Permalink
Merge pull request #572 from BloomBooks/BL13994_ReadStartsFinishes
Browse files Browse the repository at this point in the history
Grid: distinguish between read starts and finishes (BL-13994)
  • Loading branch information
andrew-polk authored Oct 24, 2024
2 parents 89cee36 + 34840a4 commit 7fad575
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
26 changes: 16 additions & 10 deletions src/components/Grid/GridColumns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -366,35 +366,41 @@ 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,
defaultVisible: false,
},
];

// 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!);
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/connection/LibraryQueryHooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
1 change: 1 addition & 0 deletions src/model/Book.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 7fad575

Please sign in to comment.