XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

XFESpaceNinjaServer

A simple server for a small space ninja game

公开
关注 0 Fork 0 Star 0
返回提交历史

XFEstudio/XFESpaceNinjaServer

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

Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/1210

818e09d4
Sainan <sainan@calamity.inc>
提交于

代码差异

5 个文件 +33 -22
Modified src/controllers/api/getGuildLogController.ts +2 -2
@@ -20,14 +20,14 @@ export const getGuildLogController: RequestHandler = async (req, res) => {
20 20 };
21 21 guild.RoomChanges?.forEach(entry => {
22 22 log.RoomChanges.push({
23 dateTime: toMongoDate(entry.dateTime),
23 dateTime: toMongoDate(entry.dateTime ?? new Date()),
24 24 entryType: entry.entryType,
25 25 details: entry.details
26 26 });
27 27 });
28 28 guild.TechChanges?.forEach(entry => {
29 29 log.TechChanges.push({
30 dateTime: toMongoDate(entry.dateTime),
30 dateTime: toMongoDate(entry.dateTime ?? new Date()),
31 31 entryType: entry.entryType,
32 32 details: entry.details
33 33 });
Modified src/controllers/api/guildTechController.ts +2 -6
@@ -216,10 +216,6 @@ export const guildTechController: RequestHandler = async (req, res) => {
216 216 const project = guild.TechProjects!.find(x => x.ItemType == data.RecipeType)!;
217 217 project.State = 0;
218 218 guild.ActiveDojoColorResearch = data.RecipeType;
219 const entry = guild.TechChanges?.find(x => x.details == data.RecipeType);
220 if (entry) {
221 entry.dateTime = new Date();
222 }
223 219 await guild.save();
224 220 res.end();
225 221 } else {
@@ -252,11 +248,11 @@ const setTechLogState = (
252 248 if (entry.entryType == state) {
253 249 return false;
254 250 }
255 entry.dateTime = dateTime ?? new Date();
251 entry.dateTime = dateTime;
256 252 entry.entryType = state;
257 253 } else {
258 254 guild.TechChanges.push({
259 dateTime: dateTime ?? new Date(),
255 dateTime: dateTime,
260 256 entryType: state,
261 257 details: type
262 258 });
Modified src/controllers/api/startDojoRecipeController.ts +0 -1
@@ -39,7 +39,6 @@ export const startDojoRecipeController: RequestHandler = async (req, res) => {
39 39
40 40 guild.RoomChanges ??= [];
41 41 guild.RoomChanges.push({
42 dateTime: new Date(),
43 42 entryType: 2,
44 43 details: request.PlacedComponent.pf,
45 44 componentId: componentId
Modified src/models/guildModel.ts +18 -8
@@ -6,9 +6,10 @@ import {
6 6 ILongMOTD,
7 7 IGuildMemberDatabase,
8 8 IGuildLogEntryNumber,
9 IGuildLogEntryString,
10 9 IGuildRank,
11 IGuildLogRoomChange
10 IGuildLogRoomChange,
11 IGuildLogEntryRoster,
12 IGuildLogEntryContributable
12 13 } from "@/src/types/guildTypes";
13 14 import { Document, Model, model, Schema, Types } from "mongoose";
14 15 import { fusionTreasuresSchema, typeCountSchema } from "./inventoryModels/inventoryModel";
@@ -108,7 +109,17 @@ const defaultRanks: IGuildRank[] = [
108 109 }
109 110 ];
110 111
111 const guildLogEntryStringSchema = new Schema<IGuildLogEntryString>(
112 const guildLogRoomChangeSchema = new Schema<IGuildLogRoomChange>(
113 {
114 dateTime: Date,
115 entryType: Number,
116 details: String,
117 componentId: Types.ObjectId
118 },
119 { _id: false }
120 );
121
122 const guildLogEntryContributableSchema = new Schema<IGuildLogEntryContributable>(
112 123 {
113 124 dateTime: Date,
114 125 entryType: Number,
@@ -117,12 +128,11 @@ const guildLogEntryStringSchema = new Schema<IGuildLogEntryString>(
117 128 { _id: false }
118 129 );
119 130
120 const guildLogRoomChangeSchema = new Schema<IGuildLogRoomChange>(
131 const guildLogEntryRosterSchema = new Schema<IGuildLogEntryRoster>(
121 132 {
122 133 dateTime: Date,
123 134 entryType: Number,
124 details: String,
125 componentId: Types.ObjectId
135 details: String
126 136 },
127 137 { _id: false }
128 138 );
@@ -161,8 +171,8 @@ const guildSchema = new Schema<IGuildDatabase>(
161 171 CeremonyResetDate: Date,
162 172 CeremonyEndo: Number,
163 173 RoomChanges: { type: [guildLogRoomChangeSchema], default: undefined },
164 TechChanges: { type: [guildLogEntryStringSchema], default: undefined },
165 RosterActivity: { type: [guildLogEntryStringSchema], default: undefined },
174 TechChanges: { type: [guildLogEntryContributableSchema], default: undefined },
175 RosterActivity: { type: [guildLogEntryRosterSchema], default: undefined },
166 176 ClassChanges: { type: [guildLogEntryNumberSchema], default: undefined }
167 177 },
168 178 { id: false }
Modified src/types/guildTypes.ts +11 -5
@@ -50,8 +50,8 @@ export interface IGuildDatabase {
50 50 CeremonyResetDate?: Date;
51 51
52 52 RoomChanges?: IGuildLogRoomChange[];
53 TechChanges?: IGuildLogEntryString[];
54 RosterActivity?: IGuildLogEntryString[];
53 TechChanges?: IGuildLogEntryContributable[];
54 RosterActivity?: IGuildLogEntryRoster[];
55 55 ClassChanges?: IGuildLogEntryNumber[];
56 56 }
57 57
@@ -190,16 +190,22 @@ export interface ITechProjectDatabase extends Omit<ITechProjectClient, "Completi
190 190 CompletionDate?: Date;
191 191 }
192 192
193 export interface IGuildLogEntryString {
194 dateTime: Date;
193 export interface IGuildLogEntryContributable {
194 dateTime?: Date;
195 195 entryType: number;
196 196 details: string;
197 197 }
198 198
199 export interface IGuildLogRoomChange extends IGuildLogEntryString {
199 export interface IGuildLogRoomChange extends IGuildLogEntryContributable {
200 200 componentId: Types.ObjectId;
201 201 }
202 202
203 export interface IGuildLogEntryRoster {
204 dateTime: Date;
205 entryType: number;
206 details: string;
207 }
208
203 209 export interface IGuildLogEntryNumber {
204 210 dateTime: Date;
205 211 entryType: number;