fix _id field in response
Some checks failed
Build / build (22) (push) Failing after 45s
Build / build (20) (push) Failing after 1m14s
Build / build (18) (push) Failing after 1m17s
Build / build (18) (pull_request) Failing after 47s
Build / build (20) (pull_request) Failing after 1m14s
Build / build (22) (pull_request) Failing after 1m14s

This commit is contained in:
Sainan 2025-03-24 14:17:07 +01:00
parent 1109d8e0ff
commit ecb0fd91e5
5 changed files with 10 additions and 6 deletions

View File

@ -8,6 +8,7 @@ import { PersonalRooms } from "@/src/models/personalRoomsModel";
import { Ship } from "@/src/models/shipModel";
import { Stats } from "@/src/models/statsModel";
import { GuildMember } from "@/src/models/guildModel";
import { Leaderboard } from "@/src/models/leaderboardModel";
export const deleteAccountController: RequestHandler = async (req, res) => {
const accountId = await getAccountIdForRequest(req);
@ -17,6 +18,7 @@ export const deleteAccountController: RequestHandler = async (req, res) => {
GuildMember.deleteMany({ accountId: accountId }),
Inbox.deleteMany({ ownerId: accountId }),
Inventory.deleteOne({ accountOwnerId: accountId }),
Leaderboard.deleteMany({ accountId: accountId }),
Loadout.deleteOne({ loadoutOwnerId: accountId }),
PersonalRooms.deleteOne({ personalRoomsOwnerId: accountId }),
Ship.deleteMany({ ShipOwnerId: accountId }),

View File

@ -4,6 +4,7 @@ import { ILeaderboardEntryDatabase } from "../types/leaderboardTypes";
const leaderboardEntrySchema = new Schema<ILeaderboardEntryDatabase>(
{
leaderboard: { type: String, required: true },
accountId: { type: Schema.Types.ObjectId, required: true },
displayName: { type: String, required: true },
score: { type: Number, required: true },
expiry: { type: Date, required: true }

View File

@ -1,9 +1,9 @@
import { toOid } from "../helpers/inventoryHelpers";
import { Leaderboard } from "../models/leaderboardModel";
import { ILeaderboardEntryClient } from "../types/leaderboardTypes";
export const submitLeaderboardScore = async (
leaderboard: string,
accountId: string,
displayName: string,
score: number
): Promise<void> => {
@ -21,7 +21,7 @@ export const submitLeaderboardScore = async (
}
await Leaderboard.findOneAndUpdate(
{ leaderboard, displayName },
{ $max: { score }, $set: { expiry } },
{ $max: { score }, $set: { accountId, expiry } },
{ upsert: true }
);
};
@ -39,7 +39,7 @@ export const getLeaderboard = async (
let r = before;
for (const entry of entries) {
res.push({
_id: toOid(entry._id),
_id: entry.accountId.toString(),
s: entry.score,
r: ++r,
n: entry.displayName

View File

@ -303,7 +303,7 @@ export const updateStats = async (accountOwnerId: string, payload: IStatsUpdate)
playerStats.Races.set(race, { highScore });
}
await submitLeaderboardScore("daily.accounts." + race, payload.displayName, highScore);
await submitLeaderboardScore("daily.accounts." + race, accountOwnerId, payload.displayName, highScore);
}
break;

View File

@ -1,14 +1,15 @@
import { IOid } from "./commonTypes";
import { Types } from "mongoose";
export interface ILeaderboardEntryDatabase {
leaderboard: string;
accountId: Types.ObjectId;
displayName: string;
score: number;
expiry: Date;
}
export interface ILeaderboardEntryClient {
_id: IOid;
_id: string; // player id
s: number; // score
r: number; // rank
n: string; // displayName