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

Function getGscQueries

packages/db/src/gsc.ts:550–585  ·  view source on GitHub ↗
(
  projectId: string,
  startDate: string,
  endDate: string,
  limit = 100
)

Source from the content-addressed store, hash-verified

548}
549
550export async function getGscQueries(
551 projectId: string,
552 startDate: string,
553 endDate: string,
554 limit = 100
555): Promise<
556 Array<{
557 query: string;
558 clicks: number;
559 impressions: number;
560 ctr: number;
561 position: number;
562 }>
563> {
564 const result = await originalCh.query({
565 query: `
566 SELECT
567 query,
568 sum(clicks) as clicks,
569 sum(impressions) as impressions,
570 avg(ctr) as ctr,
571 avg(position) as position
572 FROM gsc_queries_daily
573 FINAL
574 WHERE project_id = {projectId: String}
575 AND date >= {startDate: String}
576 AND date <= {endDate: String}
577 GROUP BY query
578 ORDER BY clicks DESC
579 LIMIT {limit: UInt32}
580 `,
581 query_params: { projectId, startDate, endDate, limit },
582 format: 'JSONEachRow',
583 });
584 return result.json();
585}

Callers 4

registerGscQueryToolsFunction · 0.90
gscGetTopQueriesCoreFunction · 0.90
gsc.tsFile · 0.90

Calls 1

queryMethod · 0.80

Tested by

no test coverage detected