Skip to content

Commit

Permalink
feat(game-history): remove unnecessary updatedAt field (#366)
Browse files Browse the repository at this point in the history
  • Loading branch information
antoinezanardi authored Aug 1, 2023
1 parent 1e4106f commit b7c1e8e
Show file tree
Hide file tree
Showing 9 changed files with 14,113 additions and 13,881 deletions.
2 changes: 2 additions & 0 deletions config/jest/jest-e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ const config: Config = {
resetMocks: true,
restoreMocks: true,
clearMocks: true,
maxConcurrency: 1,
maxWorkers: 1,
setupFilesAfterEnv: ["jest-extended/all"],
coverageReporters: ["clover", "json", "lcov", "text", "text-summary"],
collectCoverageFrom: [
Expand Down
2 changes: 2 additions & 0 deletions config/jest/jest-global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ const config: Config = {
resetMocks: true,
restoreMocks: true,
clearMocks: true,
maxConcurrency: 1,
maxWorkers: 1,
setupFiles: ["<rootDir>/tests/global-setup.ts"],
setupFilesAfterEnv: ["jest-extended/all"],
coverageReporters: ["clover", "json-summary", "lcov", "text", "text-summary"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ const gameHistoryRecordFieldsSpecs = Object.freeze<Record<keyof GameHistoryRecor
revealedPlayers: { required: false },
deadPlayers: { required: false },
createdAt: { required: true },
updatedAt: { required: true },
});

const gameHistoryRecordApiProperties = Object.freeze<Record<keyof GameHistoryRecord, ApiPropertyOptions>>({
Expand Down Expand Up @@ -63,10 +62,9 @@ const gameHistoryRecordApiProperties = Object.freeze<Record<keyof GameHistoryRec
description: "When the game history record was created",
...gameHistoryRecordFieldsSpecs.createdAt,
},
updatedAt: {
description: "When the game history record was updated",
...gameHistoryRecordFieldsSpecs.updatedAt,
},
});

export { gameHistoryRecordFieldsSpecs, gameHistoryRecordApiProperties };
export {
gameHistoryRecordFieldsSpecs,
gameHistoryRecordApiProperties,
};
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { PlayerSchema, Player } from "../player/player.schema";
import { GameHistoryRecordPlay, GameHistoryRecordPlaySchema } from "./game-history-record-play/game-history-record-play.schema";

@Schema({
timestamps: true,
timestamps: { createdAt: true, updatedAt: false },
versionKey: false,
})
class GameHistoryRecord {
Expand Down Expand Up @@ -80,10 +80,6 @@ class GameHistoryRecord {
@ApiProperty(gameHistoryRecordApiProperties.createdAt)
@Expose()
public createdAt: Date;

@ApiProperty(gameHistoryRecordApiProperties.updatedAt)
@Expose()
public updatedAt: Date;
}

const GameHistoryRecordSchema = SchemaFactory.createForClass(GameHistoryRecord);
Expand Down
2 changes: 1 addition & 1 deletion src/modules/game/types/game-history-record.type.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { OmitType } from "@nestjs/swagger";
import { GameHistoryRecord } from "../schemas/game-history-record/game-history-record.schema";

class GameHistoryRecordToInsert extends OmitType(GameHistoryRecord, ["_id", "createdAt", "updatedAt"] as const) {}
class GameHistoryRecordToInsert extends OmitType(GameHistoryRecord, ["_id", "createdAt"] as const) {}

export { GameHistoryRecordToInsert };
Original file line number Diff line number Diff line change
Expand Up @@ -809,17 +809,14 @@ describe("Game Controller", () => {
{
...toJSON(gameHistoryRecords[0]),
createdAt: expect.any(String) as Date,
updatedAt: expect.any(String) as Date,
},
{
...toJSON(gameHistoryRecords[1]),
createdAt: expect.any(String) as Date,
updatedAt: expect.any(String) as Date,
},
{
...toJSON(gameHistoryRecords[2]),
createdAt: expect.any(String) as Date,
updatedAt: expect.any(String) as Date,
},
] as GameHistoryRecord[]);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ describe("Game History Record Repository", () => {
...(toJSON(gameHistoryRecordToInsert) as GameHistoryRecordToInsert),
_id: expect.any(String) as Types.ObjectId,
createdAt: expect.any(String) as Date,
updatedAt: expect.any(String) as Date,
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,6 @@ function createFakeGameHistoryRecord(gameHistoryRecord: Partial<GameHistoryRecor
revealedPlayers: gameHistoryRecord.revealedPlayers ?? undefined,
deadPlayers: gameHistoryRecord.deadPlayers ?? undefined,
createdAt: gameHistoryRecord.createdAt ?? faker.date.recent(),
updatedAt: gameHistoryRecord.updatedAt ?? faker.date.recent(),
...override,
}, plainToInstanceDefaultOptions);
}
Expand Down
Loading

0 comments on commit b7c1e8e

Please sign in to comment.