fix search crash
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import db, { toIso, nowIso } from "../db";
|
||||
import { auditEvents } from "../db/schema";
|
||||
import { desc, ilike, or, count } from "drizzle-orm";
|
||||
import { desc, like, or, count } from "drizzle-orm";
|
||||
|
||||
export type AuditEvent = {
|
||||
id: number;
|
||||
@@ -15,9 +15,9 @@ export type AuditEvent = {
|
||||
export async function countAuditEvents(search?: string): Promise<number> {
|
||||
const where = search
|
||||
? or(
|
||||
ilike(auditEvents.summary, `%${search}%`),
|
||||
ilike(auditEvents.action, `%${search}%`),
|
||||
ilike(auditEvents.entityType, `%${search}%`)
|
||||
like(auditEvents.summary, `%${search}%`),
|
||||
like(auditEvents.action, `%${search}%`),
|
||||
like(auditEvents.entityType, `%${search}%`)
|
||||
)
|
||||
: undefined;
|
||||
const [row] = await db.select({ value: count() }).from(auditEvents).where(where);
|
||||
@@ -31,9 +31,9 @@ export async function listAuditEvents(
|
||||
): Promise<AuditEvent[]> {
|
||||
const where = search
|
||||
? or(
|
||||
ilike(auditEvents.summary, `%${search}%`),
|
||||
ilike(auditEvents.action, `%${search}%`),
|
||||
ilike(auditEvents.entityType, `%${search}%`)
|
||||
like(auditEvents.summary, `%${search}%`),
|
||||
like(auditEvents.action, `%${search}%`),
|
||||
like(auditEvents.entityType, `%${search}%`)
|
||||
)
|
||||
: undefined;
|
||||
const events = await db
|
||||
|
||||
@@ -2,7 +2,7 @@ import db, { nowIso, toIso } from "../db";
|
||||
import { applyCaddyConfig } from "../caddy";
|
||||
import { logAuditEvent } from "../audit";
|
||||
import { proxyHosts } from "../db/schema";
|
||||
import { desc, eq, count, ilike, or } from "drizzle-orm";
|
||||
import { desc, eq, count, like, or } from "drizzle-orm";
|
||||
import { getAuthentikSettings, getGeoBlockSettings, GeoBlockSettings } from "../settings";
|
||||
|
||||
const DEFAULT_AUTHENTIK_HEADERS = [
|
||||
@@ -1332,9 +1332,9 @@ export async function listProxyHosts(): Promise<ProxyHost[]> {
|
||||
export async function countProxyHosts(search?: string): Promise<number> {
|
||||
const where = search
|
||||
? or(
|
||||
ilike(proxyHosts.name, `%${search}%`),
|
||||
ilike(proxyHosts.domains, `%${search}%`),
|
||||
ilike(proxyHosts.upstreams, `%${search}%`)
|
||||
like(proxyHosts.name, `%${search}%`),
|
||||
like(proxyHosts.domains, `%${search}%`),
|
||||
like(proxyHosts.upstreams, `%${search}%`)
|
||||
)
|
||||
: undefined;
|
||||
const [row] = await db.select({ value: count() }).from(proxyHosts).where(where);
|
||||
@@ -1344,9 +1344,9 @@ export async function countProxyHosts(search?: string): Promise<number> {
|
||||
export async function listProxyHostsPaginated(limit: number, offset: number, search?: string): Promise<ProxyHost[]> {
|
||||
const where = search
|
||||
? or(
|
||||
ilike(proxyHosts.name, `%${search}%`),
|
||||
ilike(proxyHosts.domains, `%${search}%`),
|
||||
ilike(proxyHosts.upstreams, `%${search}%`)
|
||||
like(proxyHosts.name, `%${search}%`),
|
||||
like(proxyHosts.domains, `%${search}%`),
|
||||
like(proxyHosts.upstreams, `%${search}%`)
|
||||
)
|
||||
: undefined;
|
||||
const hosts = await db
|
||||
|
||||
Reference in New Issue
Block a user