Skip to content

Commit

Permalink
Merge pull request #579 from BloomBooks/BL-14205LangTagForStats
Browse files Browse the repository at this point in the history
BL-14205 Add language tag to book stats (#579)
  • Loading branch information
andrew-polk authored Jan 14, 2025
2 parents f376d32 + a0b67f0 commit 70f7c5e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/components/statistics/BookStatsReport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,16 @@ export const BookStatsReport: React.FunctionComponent<IStatsPageProps> = (
languages
)?.combined;
if (languageDisplayName) {
stat.language = languageDisplayName;
stat.languageName = languageDisplayName;
}
}
}

const columns: IGridColumn[] = [
{ name: "title", title: "Book Title", l10nId: "bookTitle" },
{ name: "branding", title: "Branding", l10nId: "branding" },
{ name: "language", title: "Language", l10nId: "language" },
{ name: "languageName", title: "Language", l10nId: "language" },
{ name: "language", title: "Language Tag", l10nId: "languageTag" },
//{ name: "extra", title: "Extra" },
{
name: "finishedCount",
Expand Down Expand Up @@ -96,6 +97,7 @@ export const BookStatsReport: React.FunctionComponent<IStatsPageProps> = (
const [tableColumnExtensions] = useState([
{ columnName: "title", width: "auto" },
{ columnName: "branding", width: "auto" },
{ columnName: "languageName", width: "auto" },
{ columnName: "language", width: "auto" },
//{ columnName: "extra", width: "auto" },

Expand Down
3 changes: 2 additions & 1 deletion src/components/statistics/StatsInterfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ export interface IBookStat {
meanCorrect: number;
medianCorrect: number;

language: string;
language: string; // IETF BCP47 language tag
languageName?: string;
/* to add
features: string;
*/
Expand Down
2 changes: 1 addition & 1 deletion src/connection/LibraryQueryHooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ export function extractBookStatFromRawData(statRow: any): IBookStat {
const stats: IBookStat = {
title: statRow.booktitle,
branding: statRow.bookbranding,
language: statRow.language,
language: statRow.language, // this is the language tag, not the name
// The parseInt and parseFloat methods are important.
// Without them, js will treat the values like strings even though typescript knows they are numbers.
// Then the + operator will concatenate instead of add.
Expand Down
2 changes: 1 addition & 1 deletion src/model/Language.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { getTranslation } from "../localization/GetLocalizations";

export interface ILanguage {
name: string;
isoCode: string;
isoCode: string; // usually just an iso 639 code, but occasionally a full tag, e.g. jmx-x-coi
usageCount: number;
englishName?: string;
bannerImageUrl?: string;
Expand Down

0 comments on commit 70f7c5e

Please sign in to comment.