Add simple stats
This commit is contained in:
parent
589dd0c328
commit
0843d51e25
2 changed files with 43 additions and 0 deletions
2
public/robots.txt
Normal file
2
public/robots.txt
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
User-agent: *
|
||||||
|
Disallow: /stats
|
41
src/pages/stats.astro
Normal file
41
src/pages/stats.astro
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
---
|
||||||
|
import { db } from "../db";
|
||||||
|
|
||||||
|
export const prerender = false;
|
||||||
|
|
||||||
|
const query = db.selectFrom("letters").select(({ fn }) => [fn.count("id").as("count")]);
|
||||||
|
|
||||||
|
const [totalSubmissions] = await query.execute();
|
||||||
|
const [confirmedSubmissions] = await query.where("confirmed", "=", 1).execute();
|
||||||
|
|
||||||
|
const submissionsByLanguage = await db
|
||||||
|
.selectFrom("letters")
|
||||||
|
.groupBy("language")
|
||||||
|
.select(({ fn }) => ["language", fn.count("id").as("count")])
|
||||||
|
.orderBy("count", "desc")
|
||||||
|
.execute();
|
||||||
|
---
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<p>Total submissions: {totalSubmissions.count}</p>
|
||||||
|
<p>Confirmed submissions: {confirmedSubmissions.count}</p>
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Lang</th>
|
||||||
|
<th>Submissions</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{
|
||||||
|
submissionsByLanguage.map((row) => (
|
||||||
|
<tr>
|
||||||
|
<th class="text-left">{row.language}</th>
|
||||||
|
<th class="text-right">{row.count}</th>
|
||||||
|
</tr>
|
||||||
|
))
|
||||||
|
}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
Reference in a new issue