mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-02-27 00:04:37 +08:00
impr: reduce number of db calls by adding a caching parameter
This commit is contained in:
parent
3adbdf2cdb
commit
25b1ecbe15
2 changed files with 6 additions and 3 deletions
|
@ -382,7 +382,7 @@ export async function getUser(
|
|||
UserDAL.flagForNameChange(uid);
|
||||
}
|
||||
|
||||
const isPremium = await UserDAL.checkIfUserIsPremium(uid);
|
||||
const isPremium = await UserDAL.checkIfUserIsPremium(uid, userInfo);
|
||||
|
||||
const userData = {
|
||||
...getRelevantUserInfo(userInfo),
|
||||
|
|
|
@ -1039,8 +1039,11 @@ export async function setBanned(uid: string, banned: boolean): Promise<void> {
|
|||
}
|
||||
}
|
||||
|
||||
export async function checkIfUserIsPremium(uid: string): Promise<boolean> {
|
||||
const user = await getUser(uid, "checkIfUserIsPremium");
|
||||
export async function checkIfUserIsPremium(
|
||||
uid: string,
|
||||
userInfoOverride?: MonkeyTypes.User
|
||||
): Promise<boolean> {
|
||||
const user = userInfoOverride ?? (await getUser(uid, "checkIfUserIsPremium"));
|
||||
const expirationDate = user.premium?.expirationTimestamp;
|
||||
|
||||
if (expirationDate === undefined) return false;
|
||||
|
|
Loading…
Reference in a new issue