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

Function getGscOverview

packages/db/src/gsc.ts:295–336  ·  view source on GitHub ↗
(
  projectId: string,
  startDate: string,
  endDate: string,
  interval: 'day' | 'week' | 'month' = 'day'
)

Source from the content-addressed store, hash-verified

293}
294
295export async function getGscOverview(
296 projectId: string,
297 startDate: string,
298 endDate: string,
299 interval: 'day' | 'week' | 'month' = 'day'
300): Promise<
301 Array<{
302 date: string;
303 clicks: number;
304 impressions: number;
305 ctr: number;
306 position: number;
307 }>
308> {
309 const dateExpr =
310 interval === 'month'
311 ? 'toStartOfMonth(date)'
312 : interval === 'week'
313 ? 'toStartOfWeek(date)'
314 : 'date';
315
316 const result = await originalCh.query({
317 query: `
318 SELECT
319 ${dateExpr} as date,
320 sum(clicks) as clicks,
321 sum(impressions) as impressions,
322 avg(ctr) as ctr,
323 avg(position) as position
324 FROM gsc_daily
325 FINAL
326 WHERE project_id = {projectId: String}
327 AND date >= {startDate: String}
328 AND date <= {endDate: String}
329 GROUP BY date
330 ORDER BY date ASC
331 `,
332 query_params: { projectId, startDate, endDate },
333 format: 'JSONEachRow',
334 });
335 return result.json();
336}
337
338export async function getGscPages(
339 projectId: string,

Callers 3

registerGscOverviewToolsFunction · 0.90
gscGetOverviewCoreFunction · 0.90
gsc.tsFile · 0.90

Calls 1

queryMethod · 0.80

Tested by

no test coverage detected