( projectId: string, startDate: string, endDate: string, limit = 100 )
| 336 | } |
| 337 | |
| 338 | export async function getGscPages( |
| 339 | projectId: string, |
| 340 | startDate: string, |
| 341 | endDate: string, |
| 342 | limit = 100 |
| 343 | ): Promise< |
| 344 | Array<{ |
| 345 | page: string; |
| 346 | clicks: number; |
| 347 | impressions: number; |
| 348 | ctr: number; |
| 349 | position: number; |
| 350 | }> |
| 351 | > { |
| 352 | const result = await originalCh.query({ |
| 353 | query: ` |
| 354 | SELECT |
| 355 | page, |
| 356 | sum(clicks) as clicks, |
| 357 | sum(impressions) as impressions, |
| 358 | avg(ctr) as ctr, |
| 359 | avg(position) as position |
| 360 | FROM gsc_pages_daily |
| 361 | FINAL |
| 362 | WHERE project_id = {projectId: String} |
| 363 | AND date >= {startDate: String} |
| 364 | AND date <= {endDate: String} |
| 365 | GROUP BY page |
| 366 | ORDER BY clicks DESC |
| 367 | LIMIT {limit: UInt32} |
| 368 | `, |
| 369 | query_params: { projectId, startDate, endDate, limit }, |
| 370 | format: 'JSONEachRow', |
| 371 | }); |
| 372 | return result.json(); |
| 373 | } |
| 374 | |
| 375 | export interface GscCannibalizedQuery { |
| 376 | query: string; |
no test coverage detected