MCPcopy Create free account
hub / github.com/Kilo-Org/cloud / replaceInQuery

Function replaceInQuery

apps/web/src/scripts/posthog/audit-microdollar-usage.ts:110–138  ·  view source on GitHub ↗
(query: unknown)

Source from the content-addressed store, hash-verified

108}
109
110function replaceInQuery(query: unknown): unknown {
111 if (!query) return query;
112
113 // Handle direct HogQLQuery
114 const hogqlResult = HogQLQuerySchema.safeParse(query);
115 if (hogqlResult.success) {
116 return {
117 ...hogqlResult.data,
118 query: hogqlResult.data.query.replace(SEARCH_REGEX, REPLACEMENT_TERM),
119 };
120 }
121
122 // Handle DataVisualizationNode with HogQL source
123 const dvnResult = _DataVisualizationNodeSchema.safeParse(query);
124 if (dvnResult.success) {
125 const sourceResult = HogQLQuerySchema.safeParse(dvnResult.data.source);
126 if (sourceResult.success) {
127 return {
128 ...dvnResult.data,
129 source: {
130 ...sourceResult.data,
131 query: sourceResult.data.query.replace(SEARCH_REGEX, REPLACEMENT_TERM),
132 },
133 };
134 }
135 }
136
137 return query;
138}
139
140async function patchView(view: DataWarehouseSavedQuery): Promise<void> {
141 if (!view.query) return;

Callers 2

patchInsightFunction · 0.85
runFunction · 0.85

Calls 1

replaceMethod · 0.65

Tested by

no test coverage detected