core: monographs stats -> monograph analytics

This commit is contained in:
Abdullah Atta
2025-11-08 12:46:58 +05:00
parent 41ad8e0988
commit 71952a354e
4 changed files with 7 additions and 21 deletions

View File

@@ -37,8 +37,8 @@ type EncryptedMonograph = MonographApiRequestBase & {
type MonographApiRequest = (UnencryptedMonograph | EncryptedMonograph) & {
userId: string;
};
export type MonographStats = {
viewCount: number;
export type MonographAnalytics = {
totalViews: number;
};
export type PublishOptions = { password?: string; selfDestruct?: boolean };
@@ -191,16 +191,12 @@ export class Monographs {
return this.db.storage().decrypt(monographPasswordsKey, password);
}
async stats(monographId: string) {
async analytics(monographId: string) {
const token = await this.db.tokenManager.getAccessToken();
const { viewCount } = (await http.get(
`${Constants.API_HOST}/monographs/${monographId}/stats`,
const analytics = (await http.get(
`${Constants.API_HOST}/monographs/${monographId}/analytics`,
token
)) as MonographStats;
await this.db.monographsCollection.add({
id: monographId,
viewCount
});
return { viewCount };
)) as MonographAnalytics;
return analytics;
}
}

View File

@@ -62,7 +62,6 @@ export class Monographs implements ICollection {
datePublished: merged.datePublished,
selfDestruct: merged.selfDestruct,
password: merged.password,
viewCount: merged.viewCount || 0,
type: "monograph"
});
}

View File

@@ -404,14 +404,6 @@ export class NNMigrationProvider implements MigrationProvider {
.addColumn("password", "text")
.execute();
}
},
"a-2025-11-05": {
async up(db) {
await db.schema
.alterTable("monographs")
.addColumn("viewCount", "integer")
.execute();
}
}
};
}

View File

@@ -498,7 +498,6 @@ export interface Monograph extends BaseItem<"monograph"> {
datePublished: number;
selfDestruct: boolean;
password?: Cipher<"base64">;
viewCount?: number;
}
export type Match = {