chuni: Correctly implement recent rating requests
This commit is contained in:
committed by
Tau
parent
6c22c4287e
commit
71a7cd7eed
@@ -2,7 +2,7 @@ import { Repositories } from "../repo";
|
||||
import { GetUserRecentRatingRequest } from "../request/getUserRecentRating";
|
||||
import { GetUserRecentRatingResponse } from "../response/getUserRecentRating";
|
||||
import { readAimeId } from "../proto/base";
|
||||
import { writeUserRecentRatingFromLog } from "../proto/userRecentRating";
|
||||
import { writeUserRecentRating } from "../proto/userRecentRating";
|
||||
|
||||
export default async function getUserRecentRating(
|
||||
rep: Repositories,
|
||||
@@ -12,11 +12,11 @@ export default async function getUserRecentRating(
|
||||
|
||||
const profileId = await rep.userData().lookup(aimeId);
|
||||
// Return recent 30 plays to calculate rating
|
||||
const items = await rep.userPlaylog().loadLatest(profileId, 30);
|
||||
const items = await rep.userRecentRating().load(profileId);
|
||||
|
||||
return {
|
||||
userId: req.userId,
|
||||
length: items.length.toString(),
|
||||
userRecentRatingList: items.map(writeUserRecentRatingFromLog),
|
||||
userRecentRatingList: items.map(writeUserRecentRating),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import { readUserDataEx } from "../proto/userDataEx";
|
||||
import { readUserDuelList } from "../proto/userDuelList";
|
||||
import { readUserPlaylog } from "../proto/userPlaylog";
|
||||
import { readUserCharge } from "../proto/userCharge";
|
||||
import { readUserRecentRating } from "../proto/userRecentRating";
|
||||
import { readUserCourse } from "../proto/userCourse";
|
||||
|
||||
// It shouldn't need to be said really, but seeing as this message (A) requires
|
||||
@@ -84,5 +85,12 @@ export default async function upsertUserAll(
|
||||
await rep.userDuelList().save(profileId, readUserDuelList(item));
|
||||
}
|
||||
|
||||
await rep
|
||||
.userRecentRating()
|
||||
.save(
|
||||
profileId,
|
||||
(payload.userRecentRatingList || []).map(readUserRecentRating)
|
||||
);
|
||||
|
||||
return { returnCode: "1" };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user