rename accountId to ownerId
Some checks failed
Build / build (18) (push) Has been cancelled
Build / build (20) (push) Has been cancelled
Build / build (22) (push) Has been cancelled
Build / build (20) (pull_request) Successful in 40s
Build / build (18) (pull_request) Successful in 1m10s
Build / build (22) (pull_request) Successful in 1m14s

This commit is contained in:
Sainan 2025-03-24 22:19:54 +01:00
parent 2fb2213c59
commit fd17fb51f5
3 changed files with 6 additions and 6 deletions

View File

@ -5,7 +5,7 @@ const leaderboardEntrySchema = new Schema<ILeaderboardEntryDatabase>(
{ {
leaderboard: { type: String, required: true }, leaderboard: { type: String, required: true },
displayName: { type: String, required: true }, displayName: { type: String, required: true },
accountId: { type: Schema.Types.ObjectId, required: true }, ownerId: { type: Schema.Types.ObjectId, required: true },
score: { type: Number, required: true }, score: { type: Number, required: true },
expiry: { type: Date, required: true } expiry: { type: Date, required: true }
}, },

View File

@ -3,7 +3,7 @@ import { ILeaderboardEntryClient } from "../types/leaderboardTypes";
export const submitLeaderboardScore = async ( export const submitLeaderboardScore = async (
leaderboard: string, leaderboard: string,
accountId: string, ownerId: string,
displayName: string, displayName: string,
score: number score: number
): Promise<void> => { ): Promise<void> => {
@ -21,7 +21,7 @@ export const submitLeaderboardScore = async (
} }
await Leaderboard.findOneAndUpdate( await Leaderboard.findOneAndUpdate(
{ leaderboard, displayName }, { leaderboard, displayName },
{ $max: { score }, $set: { accountId, expiry } }, { $max: { score }, $set: { ownerId, expiry } },
{ upsert: true } { upsert: true }
); );
}; };
@ -35,7 +35,7 @@ export const getLeaderboard = async (
let entries: TLeaderboardEntryDocument[]; let entries: TLeaderboardEntryDocument[];
let r: number; let r: number;
if (pivotId) { if (pivotId) {
const pivotDoc = await Leaderboard.findOne({ leaderboard, accountId: pivotId }); const pivotDoc = await Leaderboard.findOne({ leaderboard, ownerId: pivotId });
if (!pivotDoc) { if (!pivotDoc) {
return []; return [];
} }
@ -67,7 +67,7 @@ export const getLeaderboard = async (
const res: ILeaderboardEntryClient[] = []; const res: ILeaderboardEntryClient[] = [];
for (const entry of entries) { for (const entry of entries) {
res.push({ res.push({
_id: entry.accountId.toString(), _id: entry.ownerId.toString(),
s: entry.score, s: entry.score,
r: ++r, r: ++r,
n: entry.displayName n: entry.displayName

View File

@ -2,7 +2,7 @@ import { Types } from "mongoose";
export interface ILeaderboardEntryDatabase { export interface ILeaderboardEntryDatabase {
leaderboard: string; leaderboard: string;
accountId: Types.ObjectId; ownerId: Types.ObjectId;
displayName: string; displayName: string;
score: number; score: number;
expiry: Date; expiry: Date;