Skip to content

Commit 9ff3813

Browse files
committed
feat: add filter for intra_score_id in admin points history
1 parent cebe9b2 commit 9ff3813

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

src/routes/admin/points.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { deleteIntraScore, intraScoreSyncingPossible, syncIntraScore, syncTotalC
99
const SCORES_PER_PAGE = 100;
1010

1111
interface ScoreHistoryFilter {
12-
field: 'login' | 'type' | 'intra_type_id' | 'date' | 'coalition' | 'reason' | 'none';
12+
field: 'login' | 'type' | 'intra_type_id' | 'date' | 'coalition' | 'reason' | 'intra_score_id' | 'none';
1313
value?: string;
1414
};
1515

@@ -214,6 +214,25 @@ export const setupAdminPointsRoutes = function(app: Express, prisma: PrismaClien
214214
});
215215
});
216216

217+
app.get('/admin/points/history/intra_score_id/:intraScoreId', async (req, res) => {
218+
const intraScoreId = req.params.intraScoreId;
219+
220+
if (!intraScoreId || intraScoreId === "null") {
221+
return getScoreHistory(req, res, prisma, {
222+
intra_score_id: null,
223+
}, { field: 'intra_score_id', value: "null" });
224+
}
225+
226+
const parsedIntraScoreId = parseInt(intraScoreId);
227+
if (isNaN(parsedIntraScoreId)) {
228+
return res.status(400).send('Invalid Intra Score ID');
229+
}
230+
231+
return getScoreHistory(req, res, prisma, {
232+
intra_score_id: parsedIntraScoreId,
233+
}, { field: 'intra_score_id', value: intraScoreId });
234+
});
235+
217236
app.get('/admin/points/history/:id', async (req, res) => {
218237
const scoreId = parseInt(req.params.id);
219238
if (isNaN(scoreId)) {

templates/admin/points/history.njk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
<option value="intra_type_id" {{ "selected" if searchFilter == "intra_type_id" }}>Intra Type ID</option>
2121
<option value="date" {{ "selected" if searchFilter == "date" }}>Date (format YYYY-MM-DD)</option>
2222
<option value="coalition" {{ "selected" if searchFilter == "coalition" }}>Coalition Name</option>
23+
<option value="intra_score_id" {{ "selected" if searchFilter == "intra_score_id" }}>Intra Score ID</option>
2324
</select>
2425
</div>
2526
<div class="col">

0 commit comments

Comments
 (0)