Skip to content

Commit ded853f

Browse files
committed
feat: add most recent big contributions to coalition pages
1 parent e92998f commit ded853f

File tree

2 files changed

+70
-1
lines changed

2 files changed

+70
-1
lines changed

src/routes/home.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,11 +198,47 @@ export const setupHomeRoutes = function(app: Express, prisma: PrismaClient): voi
198198
take: 50,
199199
});
200200

201+
const latestTopScores = await prisma.codamCoalitionScore.findMany({
202+
where: {
203+
coalition_id: coalition.id,
204+
NOT: {
205+
fixed_type_id: {
206+
in: ['logtime', 'evaluation'], // Exclude logtime and evaluation scores, they are usually low
207+
}
208+
},
209+
amount: {
210+
gt: 0,
211+
},
212+
created_at: {
213+
gte: sevenDaysAgo,
214+
lte: new Date(),
215+
},
216+
},
217+
orderBy: {
218+
created_at: 'desc',
219+
},
220+
include: {
221+
user: {
222+
select: {
223+
intra_user: {
224+
select: {
225+
login: true,
226+
usual_full_name: true,
227+
image: true,
228+
},
229+
},
230+
},
231+
},
232+
},
233+
take: 25,
234+
});
235+
201236
return res.render('coalition.njk', {
202237
coalition,
203238
topContributors,
204239
topContributorsWeek,
205240
latestScores,
241+
latestTopScores,
206242
});
207243
});
208244
};

templates/coalition.njk

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,44 @@
100100
</div>
101101
</div>
102102

103+
<!-- top contributions history table (last 25 top contributions) -->
104+
<div class="row ms-0 me-0 mb-4">
105+
<div class="col">
106+
<div class="card h-100">
107+
<div class="card-header">
108+
<h5 class="card-title mb-0">Most recent big contributions</h5>
109+
</div>
110+
<div class="card-body p-0">
111+
<table class="table table-striped mb-0">
112+
<thead>
113+
<th scope="col">Date</th>
114+
<th scope="col">Student</th>
115+
<th scope="col">Points</th>
116+
<th scope="col">Reason</th>
117+
</thead>
118+
<tbody>
119+
{% for score in latestTopScores %}
120+
<tr>
121+
<td title="{{ score.created_at }}">{{ score.created_at | timeAgo }}</td>
122+
<td><a href="/profile/{{ score.user.intra_user.login | striptags(true) | escape }}">{{ score.user.intra_user.login | striptags(true) | escape }}</a></td>
123+
<td>{{ score.amount }}</td>
124+
<td style="white-space: normal; word-wrap: break-word;"><small>{{ score.reason | striptags(true) | escape }}</small></td>
125+
</tr>
126+
{% endfor %}
127+
</tbody>
128+
</table>
129+
</div>
130+
</div>
131+
</div>
132+
</div>
133+
103134
<!-- point history table (last 50 contributions) -->
135+
<!--
104136
<div class="row ms-0 me-0 mb-4">
105137
<div class="col">
106138
<div class="card h-100">
107139
<div class="card-header">
108-
<h5 class="card-title mb-0">Last 50 contributions</h5>
140+
<h5 class="card-title mb-0">Most recent contributions</h5>
109141
</div>
110142
<div class="card-body p-0">
111143
<table class="table table-striped mb-0">
@@ -130,6 +162,7 @@
130162
</div>
131163
</div>
132164
</div>
165+
-->
133166
</div>
134167

135168
{% endblock %}

0 commit comments

Comments
 (0)