mirror of
https://github.com/fosrl/pangolin.git
synced 2026-01-28 22:00:51 +00:00
♻️ list approvals with client & user data
This commit is contained in:
@@ -21,8 +21,8 @@ import type { Request, Response, NextFunction } from "express";
|
|||||||
import { build } from "@server/build";
|
import { build } from "@server/build";
|
||||||
import { getOrgTierData } from "@server/lib/billing";
|
import { getOrgTierData } from "@server/lib/billing";
|
||||||
import { TierId } from "@server/lib/billing/tiers";
|
import { TierId } from "@server/lib/billing/tiers";
|
||||||
import { approvals, db } from "@server/db";
|
import { approvals, clients, db, users } from "@server/db";
|
||||||
import { eq, sql } from "drizzle-orm";
|
import { eq, isNull, sql, not, and } from "drizzle-orm";
|
||||||
import response from "@server/lib/response";
|
import response from "@server/lib/response";
|
||||||
|
|
||||||
const paramsSchema = z.strictObject({
|
const paramsSchema = z.strictObject({
|
||||||
@@ -48,6 +48,14 @@ async function queryApprovals(orgId: string, limit: number, offset: number) {
|
|||||||
const res = await db
|
const res = await db
|
||||||
.select()
|
.select()
|
||||||
.from(approvals)
|
.from(approvals)
|
||||||
|
.leftJoin(
|
||||||
|
clients,
|
||||||
|
and(
|
||||||
|
eq(approvals.clientId, clients.clientId),
|
||||||
|
not(isNull(clients.userId)) // only user devices
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.leftJoin(users, and(eq(approvals.userId, users.userId)))
|
||||||
.where(eq(approvals.orgId, orgId))
|
.where(eq(approvals.orgId, orgId))
|
||||||
.limit(limit)
|
.limit(limit)
|
||||||
.offset(offset);
|
.offset(offset);
|
||||||
|
|||||||
Reference in New Issue
Block a user