forked from OpenWF/SpaceNinjaServer
fix: only track clan log dateTime once contributions are done (#1210)
Reviewed-on: OpenWF/SpaceNinjaServer#1210
This commit is contained in:
parent
c3a9b42fa2
commit
818e09d4af
@ -20,14 +20,14 @@ export const getGuildLogController: RequestHandler = async (req, res) => {
|
|||||||
};
|
};
|
||||||
guild.RoomChanges?.forEach(entry => {
|
guild.RoomChanges?.forEach(entry => {
|
||||||
log.RoomChanges.push({
|
log.RoomChanges.push({
|
||||||
dateTime: toMongoDate(entry.dateTime),
|
dateTime: toMongoDate(entry.dateTime ?? new Date()),
|
||||||
entryType: entry.entryType,
|
entryType: entry.entryType,
|
||||||
details: entry.details
|
details: entry.details
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
guild.TechChanges?.forEach(entry => {
|
guild.TechChanges?.forEach(entry => {
|
||||||
log.TechChanges.push({
|
log.TechChanges.push({
|
||||||
dateTime: toMongoDate(entry.dateTime),
|
dateTime: toMongoDate(entry.dateTime ?? new Date()),
|
||||||
entryType: entry.entryType,
|
entryType: entry.entryType,
|
||||||
details: entry.details
|
details: entry.details
|
||||||
});
|
});
|
||||||
|
@ -216,10 +216,6 @@ export const guildTechController: RequestHandler = async (req, res) => {
|
|||||||
const project = guild.TechProjects!.find(x => x.ItemType == data.RecipeType)!;
|
const project = guild.TechProjects!.find(x => x.ItemType == data.RecipeType)!;
|
||||||
project.State = 0;
|
project.State = 0;
|
||||||
guild.ActiveDojoColorResearch = data.RecipeType;
|
guild.ActiveDojoColorResearch = data.RecipeType;
|
||||||
const entry = guild.TechChanges?.find(x => x.details == data.RecipeType);
|
|
||||||
if (entry) {
|
|
||||||
entry.dateTime = new Date();
|
|
||||||
}
|
|
||||||
await guild.save();
|
await guild.save();
|
||||||
res.end();
|
res.end();
|
||||||
} else {
|
} else {
|
||||||
@ -252,11 +248,11 @@ const setTechLogState = (
|
|||||||
if (entry.entryType == state) {
|
if (entry.entryType == state) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
entry.dateTime = dateTime ?? new Date();
|
entry.dateTime = dateTime;
|
||||||
entry.entryType = state;
|
entry.entryType = state;
|
||||||
} else {
|
} else {
|
||||||
guild.TechChanges.push({
|
guild.TechChanges.push({
|
||||||
dateTime: dateTime ?? new Date(),
|
dateTime: dateTime,
|
||||||
entryType: state,
|
entryType: state,
|
||||||
details: type
|
details: type
|
||||||
});
|
});
|
||||||
|
@ -39,7 +39,6 @@ export const startDojoRecipeController: RequestHandler = async (req, res) => {
|
|||||||
|
|
||||||
guild.RoomChanges ??= [];
|
guild.RoomChanges ??= [];
|
||||||
guild.RoomChanges.push({
|
guild.RoomChanges.push({
|
||||||
dateTime: new Date(),
|
|
||||||
entryType: 2,
|
entryType: 2,
|
||||||
details: request.PlacedComponent.pf,
|
details: request.PlacedComponent.pf,
|
||||||
componentId: componentId
|
componentId: componentId
|
||||||
|
@ -6,9 +6,10 @@ import {
|
|||||||
ILongMOTD,
|
ILongMOTD,
|
||||||
IGuildMemberDatabase,
|
IGuildMemberDatabase,
|
||||||
IGuildLogEntryNumber,
|
IGuildLogEntryNumber,
|
||||||
IGuildLogEntryString,
|
|
||||||
IGuildRank,
|
IGuildRank,
|
||||||
IGuildLogRoomChange
|
IGuildLogRoomChange,
|
||||||
|
IGuildLogEntryRoster,
|
||||||
|
IGuildLogEntryContributable
|
||||||
} 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";
|
||||||
@ -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,
|
dateTime: Date,
|
||||||
entryType: Number,
|
entryType: Number,
|
||||||
@ -117,12 +128,11 @@ const guildLogEntryStringSchema = new Schema<IGuildLogEntryString>(
|
|||||||
{ _id: false }
|
{ _id: false }
|
||||||
);
|
);
|
||||||
|
|
||||||
const guildLogRoomChangeSchema = new Schema<IGuildLogRoomChange>(
|
const guildLogEntryRosterSchema = new Schema<IGuildLogEntryRoster>(
|
||||||
{
|
{
|
||||||
dateTime: Date,
|
dateTime: Date,
|
||||||
entryType: Number,
|
entryType: Number,
|
||||||
details: String,
|
details: String
|
||||||
componentId: Types.ObjectId
|
|
||||||
},
|
},
|
||||||
{ _id: false }
|
{ _id: false }
|
||||||
);
|
);
|
||||||
@ -161,8 +171,8 @@ const guildSchema = new Schema<IGuildDatabase>(
|
|||||||
CeremonyResetDate: Date,
|
CeremonyResetDate: Date,
|
||||||
CeremonyEndo: Number,
|
CeremonyEndo: Number,
|
||||||
RoomChanges: { type: [guildLogRoomChangeSchema], default: undefined },
|
RoomChanges: { type: [guildLogRoomChangeSchema], default: undefined },
|
||||||
TechChanges: { type: [guildLogEntryStringSchema], default: undefined },
|
TechChanges: { type: [guildLogEntryContributableSchema], default: undefined },
|
||||||
RosterActivity: { type: [guildLogEntryStringSchema], default: undefined },
|
RosterActivity: { type: [guildLogEntryRosterSchema], default: undefined },
|
||||||
ClassChanges: { type: [guildLogEntryNumberSchema], default: undefined }
|
ClassChanges: { type: [guildLogEntryNumberSchema], default: undefined }
|
||||||
},
|
},
|
||||||
{ id: false }
|
{ id: false }
|
||||||
|
@ -50,8 +50,8 @@ export interface IGuildDatabase {
|
|||||||
CeremonyResetDate?: Date;
|
CeremonyResetDate?: Date;
|
||||||
|
|
||||||
RoomChanges?: IGuildLogRoomChange[];
|
RoomChanges?: IGuildLogRoomChange[];
|
||||||
TechChanges?: IGuildLogEntryString[];
|
TechChanges?: IGuildLogEntryContributable[];
|
||||||
RosterActivity?: IGuildLogEntryString[];
|
RosterActivity?: IGuildLogEntryRoster[];
|
||||||
ClassChanges?: IGuildLogEntryNumber[];
|
ClassChanges?: IGuildLogEntryNumber[];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -190,16 +190,22 @@ export interface ITechProjectDatabase extends Omit<ITechProjectClient, "Completi
|
|||||||
CompletionDate?: Date;
|
CompletionDate?: Date;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IGuildLogEntryString {
|
export interface IGuildLogEntryContributable {
|
||||||
dateTime: Date;
|
dateTime?: Date;
|
||||||
entryType: number;
|
entryType: number;
|
||||||
details: string;
|
details: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IGuildLogRoomChange extends IGuildLogEntryString {
|
export interface IGuildLogRoomChange extends IGuildLogEntryContributable {
|
||||||
componentId: Types.ObjectId;
|
componentId: Types.ObjectId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface IGuildLogEntryRoster {
|
||||||
|
dateTime: Date;
|
||||||
|
entryType: number;
|
||||||
|
details: string;
|
||||||
|
}
|
||||||
|
|
||||||
export interface IGuildLogEntryNumber {
|
export interface IGuildLogEntryNumber {
|
||||||
dateTime: Date;
|
dateTime: Date;
|
||||||
entryType: number;
|
entryType: number;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user