MCPcopy Create free account
hub / github.com/Openpanel-dev/openpanel / getImportDateBounds

Function getImportDateBounds

packages/db/src/services/import.service.ts:593–618  ·  view source on GitHub ↗
(
  importId: string,
  fromCreatedAt?: string
)

Source from the content-addressed store, hash-verified

591 * Get min/max created_at for an import's staging data.
592 */
593export async function getImportDateBounds(
594 importId: string,
595 fromCreatedAt?: string
596): Promise<{ min: string | null; max: string | null }> {
597 const res = await ch.query({
598 query: `
599 SELECT min(created_at) AS min, max(created_at) AS max
600 FROM ${TABLE_NAMES.events_imports}
601 WHERE import_id = {importId:String}
602 AND name NOT IN ('session_start', 'session_end')
603 ${fromCreatedAt ? 'AND created_at >= {fromCreatedAt:String}' : ''}
604 `,
605 query_params: { importId, fromCreatedAt },
606 format: 'JSONEachRow',
607 });
608 const rows = (await res.json()) as Array<{
609 min: string | null;
610 max: string | null;
611 }>;
612 return rows.length > 0
613 ? {
614 min: fromCreatedAt ?? rows[0]?.min ?? null,
615 max: rows[0]?.max ?? null,
616 }
617 : { min: null, max: null };
618}
619
620export type UpdateImportStatusOptions =
621 | {

Callers 1

importJobFunction · 0.90

Calls 1

queryMethod · 0.80

Tested by

no test coverage detected