Skip to content

Commit 9b16f1a

Browse files
committed
Rename attemptCompletedAt field to lastSubmittedAttemptAt
1 parent 2d4f2be commit 9b16f1a

File tree

4 files changed

+9
-10
lines changed

4 files changed

+9
-10
lines changed

backend/question-service/controllers/historyController.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export const getUserHistoryEntries = async (req: any, res: Response) => {
2323
key: entry._id,
2424
roomId: entry.roomId,
2525
attemptStartedAt: entry.attemptStartedAt.getTime(),
26-
attemptCompletedAt: entry.attemptCompletedAt.getTime(),
26+
lastAttemptSubmittedAt: entry.lastAttemptSubmittedAt.getTime(),
2727
title: entry.question.title,
2828
difficulty: entry.question.difficulty,
2929
topics: entry.question.categories.map((cat: any) => cat.name),
@@ -48,10 +48,10 @@ export const createOrUpdateUserHistoryEntry = async (req: any, res: Response) =>
4848

4949
const existingEntry = await historyEntryModel.findOne({ userId, roomId });
5050

51-
if (!isInitial && existingEntry) {
51+
if (!isInitial && existingEntry && attemptCode && attemptCode !== "") {
5252
existingEntry.question = questionId;
5353
existingEntry.attemptStartedAt = attemptStartedAt;
54-
existingEntry.attemptCompletedAt = attemptCompletedAt;
54+
existingEntry.lastAttemptSubmittedAt = attemptCompletedAt;
5555
existingEntry.collaboratorId = collaboratorId;
5656
existingEntry.attemptCodes.push(attemptCode);
5757

backend/question-service/models/HistoryEntry.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export interface HistoryEntry extends mongoose.Document {
77
question: Question;
88
roomId: string; // Note: This should not be used to retrieve the room from matching service! This is only here to serve as a uniqueness check for updating attempt information!
99
attemptStartedAt: Date;
10-
attemptCompletedAt: Date;
10+
lastAttemptSubmittedAt: Date;
1111
collaboratorId: string;
1212
attemptCodes: string[];
1313
}
@@ -17,7 +17,7 @@ const historyEntrySchema: Schema = new Schema<HistoryEntry>({
1717
question: { type: Schema.Types.ObjectId, ref: 'question', required: true },
1818
roomId: { type: String, required: true, unique: false },
1919
attemptStartedAt: { type: Date, required: true, default: Date.now() },
20-
attemptCompletedAt: { type: Date, required: true, default: Date.now() },
20+
lastAttemptSubmittedAt: { type: Date, required: true, default: Date.now() },
2121
collaboratorId: { type: String, required: true },
2222
attemptCodes: [{ type: String }],
2323
});

frontend/src/domain/entities/HistoryEntry.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ export interface HistoryEntry {
33
key: string;
44
roomId: string;
55
attemptStartedAt: string;
6-
attemptCompletedAt: string;
6+
lastAttemptSubmittedAt: string;
77
title: string;
88
difficulty: 'Easy' | 'Medium' | 'Hard';
99
topics: string[];

frontend/src/presentation/components/RecentAttemptsTable.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,11 @@ export const RecentAttemptsTable: React.FC = () => {
139139
title: 'Date',
140140
dataIndex: 'date',
141141
key: 'date',
142-
sorter: (a, b) => new Date(a.attemptCompletedAt).getTime() - new Date(b.attemptCompletedAt).getTime(),
142+
sorter: (a, b) => new Date(a.lastAttemptSubmittedAt).getTime() - new Date(b.lastAttemptSubmittedAt).getTime(),
143143
render: (_text, record) => {
144144
const formattedStartDate = formatDate(record.attemptStartedAt);
145-
const formattedEndDate = formatDate(record.attemptCompletedAt);
146-
const duration = calculateDuration(record.attemptStartedAt, record.attemptCompletedAt);
145+
const formattedEndDate = formatDate(record.lastAttemptSubmittedAt);
146+
const duration = calculateDuration(record.attemptStartedAt, record.lastAttemptSubmittedAt);
147147
return (
148148
<div className={styles.dateContainer}>
149149
<div>
@@ -279,7 +279,6 @@ export const RecentAttemptsTable: React.FC = () => {
279279
</Button>,
280280
]}
281281
width={900}
282-
bodyStyle={{ padding: 0 }}
283282
>
284283
{currentCodes.length > 0 ? (
285284
<Tabs

0 commit comments

Comments
 (0)