feat: track ClassChanges in clan log (#1157)
Re #1152 Reviewed-on: #1157
This commit is contained in:
parent
7acb54922f
commit
be6e5ce250
@ -20,6 +20,12 @@ export const contributeGuildClassController: RequestHandler = async (req, res) =
|
|||||||
for (let i = guild.Class; i != guild.CeremonyClass; ++i) {
|
for (let i = guild.Class; i != guild.CeremonyClass; ++i) {
|
||||||
guild.CeremonyEndo += (i + 1) * 1000;
|
guild.CeremonyEndo += (i + 1) * 1000;
|
||||||
}
|
}
|
||||||
|
guild.ClassChanges ??= [];
|
||||||
|
guild.ClassChanges.push({
|
||||||
|
dateTime: new Date(),
|
||||||
|
entryType: 13,
|
||||||
|
details: guild.CeremonyClass
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
guild.CeremonyContributors.push(new Types.ObjectId(accountId));
|
guild.CeremonyContributors.push(new Types.ObjectId(accountId));
|
||||||
|
@ -1,11 +1,37 @@
|
|||||||
|
import { toMongoDate } from "@/src/helpers/inventoryHelpers";
|
||||||
|
import { Guild } from "@/src/models/guildModel";
|
||||||
|
import { getInventory } from "@/src/services/inventoryService";
|
||||||
|
import { getAccountIdForRequest } from "@/src/services/loginService";
|
||||||
|
import { IMongoDate } from "@/src/types/commonTypes";
|
||||||
import { RequestHandler } from "express";
|
import { RequestHandler } from "express";
|
||||||
|
|
||||||
export const getGuildLogController: RequestHandler = (_req, res) => {
|
export const getGuildLogController: RequestHandler = async (req, res) => {
|
||||||
res.json({
|
const log: Record<string, IGuildLogEntryClient[]> = {
|
||||||
RoomChanges: [],
|
RoomChanges: [],
|
||||||
TechChanges: [],
|
TechChanges: [],
|
||||||
RosterActivity: [],
|
RosterActivity: [],
|
||||||
StandingsUpdates: [],
|
StandingsUpdates: [],
|
||||||
ClassChanges: []
|
ClassChanges: []
|
||||||
});
|
};
|
||||||
|
const accountId = await getAccountIdForRequest(req);
|
||||||
|
const inventory = await getInventory(accountId);
|
||||||
|
if (inventory.GuildId) {
|
||||||
|
const guild = await Guild.findOne({ _id: inventory.GuildId });
|
||||||
|
if (guild) {
|
||||||
|
guild.ClassChanges?.forEach(entry => {
|
||||||
|
log.ClassChanges.push({
|
||||||
|
dateTime: toMongoDate(entry.dateTime),
|
||||||
|
entryType: entry.entryType,
|
||||||
|
details: entry.details
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
res.json(log);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
interface IGuildLogEntryClient {
|
||||||
|
dateTime: IMongoDate;
|
||||||
|
entryType: number;
|
||||||
|
details: number | string;
|
||||||
|
}
|
||||||
|
@ -5,7 +5,8 @@ import {
|
|||||||
ITechProjectClient,
|
ITechProjectClient,
|
||||||
IDojoDecoDatabase,
|
IDojoDecoDatabase,
|
||||||
ILongMOTD,
|
ILongMOTD,
|
||||||
IGuildMemberDatabase
|
IGuildMemberDatabase,
|
||||||
|
IGuildLogClassChange
|
||||||
} from "@/src/types/guildTypes";
|
} from "@/src/types/guildTypes";
|
||||||
import { Document, Model, model, Schema, Types } from "mongoose";
|
import { Document, Model, model, Schema, Types } from "mongoose";
|
||||||
import { fusionTreasuresSchema, typeCountSchema } from "./inventoryModels/inventoryModel";
|
import { fusionTreasuresSchema, typeCountSchema } from "./inventoryModels/inventoryModel";
|
||||||
@ -69,6 +70,15 @@ const longMOTDSchema = new Schema<ILongMOTD>(
|
|||||||
{ _id: false }
|
{ _id: false }
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const guildLogClassChangeSchema = new Schema<IGuildLogClassChange>(
|
||||||
|
{
|
||||||
|
dateTime: Date,
|
||||||
|
entryType: Number,
|
||||||
|
details: Number
|
||||||
|
},
|
||||||
|
{ _id: false }
|
||||||
|
);
|
||||||
|
|
||||||
const guildSchema = new Schema<IGuildDatabase>(
|
const guildSchema = new Schema<IGuildDatabase>(
|
||||||
{
|
{
|
||||||
Name: { type: String, required: true, unique: true },
|
Name: { type: String, required: true, unique: true },
|
||||||
@ -89,7 +99,8 @@ const guildSchema = new Schema<IGuildDatabase>(
|
|||||||
CeremonyClass: Number,
|
CeremonyClass: Number,
|
||||||
CeremonyContributors: { type: [Types.ObjectId], default: undefined },
|
CeremonyContributors: { type: [Types.ObjectId], default: undefined },
|
||||||
CeremonyResetDate: Date,
|
CeremonyResetDate: Date,
|
||||||
CeremonyEndo: Number
|
CeremonyEndo: Number,
|
||||||
|
ClassChanges: { type: [guildLogClassChangeSchema], default: undefined }
|
||||||
},
|
},
|
||||||
{ id: false }
|
{ id: false }
|
||||||
);
|
);
|
||||||
|
@ -46,6 +46,8 @@ export interface IGuildDatabase {
|
|||||||
CeremonyEndo?: number;
|
CeremonyEndo?: number;
|
||||||
CeremonyContributors?: Types.ObjectId[];
|
CeremonyContributors?: Types.ObjectId[];
|
||||||
CeremonyResetDate?: Date;
|
CeremonyResetDate?: Date;
|
||||||
|
|
||||||
|
ClassChanges?: IGuildLogClassChange[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ILongMOTD {
|
export interface ILongMOTD {
|
||||||
@ -160,3 +162,9 @@ export interface ITechProjectClient {
|
|||||||
export interface ITechProjectDatabase extends Omit<ITechProjectClient, "CompletionDate"> {
|
export interface ITechProjectDatabase extends Omit<ITechProjectClient, "CompletionDate"> {
|
||||||
CompletionDate?: Date;
|
CompletionDate?: Date;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface IGuildLogClassChange {
|
||||||
|
dateTime: Date;
|
||||||
|
entryType: number;
|
||||||
|
details: number;
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user