( projectId: string, startDate: string, endDate: string, limit = 100 )
| 548 | } |
| 549 | |
| 550 | export 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 | } |
no test coverage detected