mirror of
https://github.com/fosrl/pangolin.git
synced 2026-03-11 21:26:37 +00:00
🏷️ fix type for SQLite
This commit is contained in:
@@ -97,19 +97,15 @@ async function query(query: Q) {
|
|||||||
|
|
||||||
const groupByDayFunction =
|
const groupByDayFunction =
|
||||||
driver === "pg"
|
driver === "pg"
|
||||||
? sql<string>`DATE_TRUNC('day', TO_TIMESTAMP(${requestAuditLog.timestamp}))`.as(
|
? sql<string>`DATE_TRUNC('day', TO_TIMESTAMP(${requestAuditLog.timestamp}))`
|
||||||
"day"
|
: sql<string>`DATE(${requestAuditLog.timestamp}, 'unixepoch')`;
|
||||||
)
|
|
||||||
: sql<string>`DATE(${requestAuditLog.timestamp}, 'unixepoch')`.as(
|
|
||||||
"day"
|
|
||||||
);
|
|
||||||
|
|
||||||
const booleanTrue = driver === "pg" ? sql`true` : sql`1`;
|
const booleanTrue = driver === "pg" ? sql`true` : sql`1`;
|
||||||
const booleanFalse = driver === "pg" ? sql`false` : sql`0`;
|
const booleanFalse = driver === "pg" ? sql`false` : sql`0`;
|
||||||
|
|
||||||
const requestsPerDay = await db
|
const requestsPerDay = await db
|
||||||
.select({
|
.select({
|
||||||
day: groupByDayFunction,
|
day: groupByDayFunction.as("day"),
|
||||||
allowedCount:
|
allowedCount:
|
||||||
sql<number>`SUM(CASE WHEN ${requestAuditLog.action} = ${booleanTrue} THEN 1 ELSE 0 END)`.as(
|
sql<number>`SUM(CASE WHEN ${requestAuditLog.action} = ${booleanTrue} THEN 1 ELSE 0 END)`.as(
|
||||||
"allowed_count"
|
"allowed_count"
|
||||||
|
|||||||
Reference in New Issue
Block a user