Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions backend/question-service/controllers/historyController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,24 @@ export const getUserHistoryEntries = async (req: any, res: Response) => {
model: "category",
},
});

historyEntries.forEach(async (entry) => {
if (entry.question === null) {
await historyEntryModel.findByIdAndDelete({_id: entry._id});
}
})

const historyViewModels = historyEntries
.filter((entry) => !(entry.question === null))
.map((entry) => {
const attemptStartDate = new Date(entry.attemptStartedAt);
const timeDiffMs = Date.now() - attemptStartDate.getTime();
const isWithin24Hours = timeDiffMs < 86400000; // 1 Day; Same as ROOM_LIFESPAN in MatchingService. Can be different if desired.

return {
id: entry._id,
key: entry._id,
roomId: entry.roomId,
roomId: isWithin24Hours ? entry.roomId : null,
attemptStartedAt: entry.attemptStartedAt.getTime(),
lastAttemptSubmittedAt: entry.lastAttemptSubmittedAt.getTime(),
title: entry.question.title,
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/domain/entities/HistoryEntry.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export interface HistoryEntry {
_id: string;
key: string;
roomId: string;
roomId?: string; // If null, room is expired
attemptStartedAt: string;
lastAttemptSubmittedAt: string;
title: string;
Expand Down
18 changes: 10 additions & 8 deletions frontend/src/presentation/components/RecentAttemptsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -238,14 +238,16 @@ export const RecentAttemptsTable: React.FC = () => {
>
View Past Code
</Button>
<Button
type="link"
onClick={() => navigate(`/room/${record.roomId}`)}
icon={<TeamOutlined />}
aria-label={`Rejoin room ${record.roomId}`}
>
Rejoin
</Button>
{record.roomId && (
<Button
type="link"
onClick={() => navigate(`/room/${record.roomId}`)}
icon={<TeamOutlined />}
aria-label={`Rejoin room ${record.roomId}`}
>
Rejoin
</Button>
)}
</Space>
),
},
Expand Down
Loading