All files / src/lib track-localities.ts

100% Statements 17/17
100% Branches 8/8
100% Functions 2/2
100% Lines 17/17

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22    1x 1x 1x 1x 1x 1x 1x   1x 5x 5x 3x 5x 5x   1x 4x 2x 2x  
import type { Prisma } from "@prisma/client";
 
export const trackLocalitiesQuerystringSchema = {
  type: "object",
  additionalProperties: false,
  properties: {
    q: { type: "string" },
  },
} as const;
 
export function parseLocalitiesQuery(query: Record<string, unknown>): { q?: string } {
  const raw = query.q;
  if (typeof raw !== "string") return {};
  const q = raw.trim();
  return q.length > 0 ? { q } : {};
}
 
export function buildLocalitiesWhere(q?: string): Prisma.GpxTrackWhereInput | undefined {
  if (!q) return undefined;
  return { locality: { contains: q, mode: "insensitive" } };
}