MCPcopy
hub / github.com/msgbyte/tianji / getDateQuery

Function getDateQuery

src/server/model/insights/shared.ts:77–92  ·  view source on GitHub ↗
(
    field: string,
    unit: string,
    timezone: string
  )

Source from the content-addressed store, hash-verified

75 }
76
77 protected getDateQuery(
78 field: string,
79 unit: string,
80 timezone: string
81 ): Prisma.Sql {
82 if (this.shouldUseClickhouse()) {
83 return this.getClickHouseDateQuery(field, unit, timezone);
84 }
85
86 // Check if unit exists in POSTGRESQL_DATE_FORMATS before using it
87 if (!(unit in POSTGRESQL_DATE_FORMATS)) {
88 throw new Error(`Invalid date unit: ${unit}`);
89 }
90
91 return sql`to_char(date_trunc(${unit}, ${raw(field)} at time zone ${timezone}), '${raw(POSTGRESQL_DATE_FORMATS[unit as keyof typeof POSTGRESQL_DATE_FORMATS])}')`;
92 }
93
94 protected getClickHouseDateQuery(
95 field: string,

Callers 10

getSurveyStatsFunction · 0.50
getTelemetryPageviewFunction · 0.50
getTelemetrySessionFunction · 0.50
getTelemetryStatsFunction · 0.50
getApplicationEventStatsFunction · 0.50
getMonitorSummaryWithDayFunction · 0.50
getWorkspaceWebsiteStatsFunction · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected