feat(web): add user ID and name to transaction details for better tracking
This commit is contained in:
@@ -2,6 +2,7 @@ import { Hono } from "hono";
|
||||
import { and, desc, eq, isNull, isNotNull, sql } from "drizzle-orm";
|
||||
import { useDrizzle } from "@/lib/db.js";
|
||||
import { transaction, chargePoint, connector, idTag } from "@/db/schema.js";
|
||||
import { user } from "@/db/auth-schema.js";
|
||||
import { ocppConnections } from "@/ocpp/handler.js";
|
||||
import { OCPP_MESSAGE_TYPE } from "@/ocpp/types.js";
|
||||
import type { HonoEnv } from "@/types/hono.ts";
|
||||
@@ -47,10 +48,14 @@ app.get("/", async (c) => {
|
||||
transaction,
|
||||
chargePointIdentifier: chargePoint.chargePointIdentifier,
|
||||
connectorNumber: connector.connectorId,
|
||||
idTagUserId: idTag.userId,
|
||||
idTagUserName: user.name,
|
||||
})
|
||||
.from(transaction)
|
||||
.leftJoin(chargePoint, eq(transaction.chargePointId, chargePoint.id))
|
||||
.leftJoin(connector, eq(transaction.connectorId, connector.id))
|
||||
.leftJoin(idTag, eq(transaction.idTag, idTag.idTag))
|
||||
.leftJoin(user, eq(idTag.userId, user.id))
|
||||
.where(whereClause)
|
||||
.orderBy(desc(transaction.startTimestamp))
|
||||
.limit(limit)
|
||||
@@ -61,6 +66,8 @@ app.get("/", async (c) => {
|
||||
...r.transaction,
|
||||
chargePointIdentifier: r.chargePointIdentifier,
|
||||
connectorNumber: r.connectorNumber,
|
||||
idTagUserId: r.idTagUserId,
|
||||
idTagUserName: r.idTagUserName,
|
||||
energyWh:
|
||||
r.transaction.stopMeterValue != null
|
||||
? r.transaction.stopMeterValue - r.transaction.startMeterValue
|
||||
|
||||
Reference in New Issue
Block a user