fix: only track clan log dateTime once contributions are done (#1210)

Reviewed-on: OpenWF/SpaceNinjaServer#1210
This commit is contained in:
Sainan 2025-03-16 08:16:11 -07:00
parent c3a9b42fa2
commit 818e09d4af
5 changed files with 33 additions and 22 deletions

View File

@ -20,14 +20,14 @@ export const getGuildLogController: RequestHandler = async (req, res) => {
};
guild.RoomChanges?.forEach(entry => {
log.RoomChanges.push({
dateTime: toMongoDate(entry.dateTime),
dateTime: toMongoDate(entry.dateTime ?? new Date()),
entryType: entry.entryType,
details: entry.details
});
});
guild.TechChanges?.forEach(entry => {
log.TechChanges.push({
dateTime: toMongoDate(entry.dateTime),
dateTime: toMongoDate(entry.dateTime ?? new Date()),
entryType: entry.entryType,
details: entry.details
});

View File

@ -216,10 +216,6 @@ export const guildTechController: RequestHandler = async (req, res) => {
const project = guild.TechProjects!.find(x => x.ItemType == data.RecipeType)!;
project.State = 0;
guild.ActiveDojoColorResearch = data.RecipeType;
const entry = guild.TechChanges?.find(x => x.details == data.RecipeType);
if (entry) {
entry.dateTime = new Date();
}
await guild.save();
res.end();
} else {
@ -252,11 +248,11 @@ const setTechLogState = (
if (entry.entryType == state) {
return false;
}
entry.dateTime = dateTime ?? new Date();
entry.dateTime = dateTime;
entry.entryType = state;
} else {
guild.TechChanges.push({
dateTime: dateTime ?? new Date(),
dateTime: dateTime,
entryType: state,
details: type
});

View File

@ -39,7 +39,6 @@ export const startDojoRecipeController: RequestHandler = async (req, res) => {
guild.RoomChanges ??= [];
guild.RoomChanges.push({
dateTime: new Date(),
entryType: 2,
details: request.PlacedComponent.pf,
componentId: componentId

View File

@ -6,9 +6,10 @@ import {
ILongMOTD,
IGuildMemberDatabase,
IGuildLogEntryNumber,
IGuildLogEntryString,
IGuildRank,
IGuildLogRoomChange
IGuildLogRoomChange,
IGuildLogEntryRoster,
IGuildLogEntryContributable
} from "@/src/types/guildTypes";
import { Document, Model, model, Schema, Types } from "mongoose";
import { fusionTreasuresSchema, typeCountSchema } from "./inventoryModels/inventoryModel";
@ -108,7 +109,17 @@ const defaultRanks: IGuildRank[] = [
}
];
const guildLogEntryStringSchema = new Schema<IGuildLogEntryString>(
const guildLogRoomChangeSchema = new Schema<IGuildLogRoomChange>(
{
dateTime: Date,
entryType: Number,
details: String,
componentId: Types.ObjectId
},
{ _id: false }
);
const guildLogEntryContributableSchema = new Schema<IGuildLogEntryContributable>(
{
dateTime: Date,
entryType: Number,
@ -117,12 +128,11 @@ const guildLogEntryStringSchema = new Schema<IGuildLogEntryString>(
{ _id: false }
);
const guildLogRoomChangeSchema = new Schema<IGuildLogRoomChange>(
const guildLogEntryRosterSchema = new Schema<IGuildLogEntryRoster>(
{
dateTime: Date,
entryType: Number,
details: String,
componentId: Types.ObjectId
details: String
},
{ _id: false }
);
@ -161,8 +171,8 @@ const guildSchema = new Schema<IGuildDatabase>(
CeremonyResetDate: Date,
CeremonyEndo: Number,
RoomChanges: { type: [guildLogRoomChangeSchema], default: undefined },
TechChanges: { type: [guildLogEntryStringSchema], default: undefined },
RosterActivity: { type: [guildLogEntryStringSchema], default: undefined },
TechChanges: { type: [guildLogEntryContributableSchema], default: undefined },
RosterActivity: { type: [guildLogEntryRosterSchema], default: undefined },
ClassChanges: { type: [guildLogEntryNumberSchema], default: undefined }
},
{ id: false }

View File

@ -50,8 +50,8 @@ export interface IGuildDatabase {
CeremonyResetDate?: Date;
RoomChanges?: IGuildLogRoomChange[];
TechChanges?: IGuildLogEntryString[];
RosterActivity?: IGuildLogEntryString[];
TechChanges?: IGuildLogEntryContributable[];
RosterActivity?: IGuildLogEntryRoster[];
ClassChanges?: IGuildLogEntryNumber[];
}
@ -190,16 +190,22 @@ export interface ITechProjectDatabase extends Omit<ITechProjectClient, "Completi
CompletionDate?: Date;
}
export interface IGuildLogEntryString {
dateTime: Date;
export interface IGuildLogEntryContributable {
dateTime?: Date;
entryType: number;
details: string;
}
export interface IGuildLogRoomChange extends IGuildLogEntryString {
export interface IGuildLogRoomChange extends IGuildLogEntryContributable {
componentId: Types.ObjectId;
}
export interface IGuildLogEntryRoster {
dateTime: Date;
entryType: number;
details: string;
}
export interface IGuildLogEntryNumber {
dateTime: Date;
entryType: number;