chuni: Add recent rating response to fix rating calculation

This commit is contained in:
NeumPhis
2019-11-27 01:49:05 +00:00
committed by Tau
parent 60d2f7cfd3
commit c2c25149b3
4 changed files with 36 additions and 4 deletions
+13 -1
View File
@@ -7,7 +7,7 @@ import { UserPlaylogRepository } from "../repo/userPlaylog";
import { Transaction } from "../../sql";
import { T, createSqlMapper } from "../../sql/util";
const { writeRow } = createSqlMapper({
const { readRow, writeRow } = createSqlMapper({
orderId: T.number,
sortNumber: T.number,
placeId: T.number,
@@ -72,4 +72,16 @@ export class SqlUserPlaylogRepository implements UserPlaylogRepository {
return this._txn.modify(stmt);
}
async loadLatest(profileId: Id<UserDataItem>, size: number): Promise<UserPlaylogItem[]> {
const stmt = sql
.select("music_id", "score", "level","user_play_date")
.from("cm_user_playlog")
.where("profile_id", profileId)
.limit(size).order("user_play_date DESC");
const rows = await this._txn.fetchRows(stmt);
return rows.map(readRow);
}
}