(input: {
projectId: string;
startDate: string;
endDate: string;
interval?: 'day' | 'week' | 'month';
})
| 70 | } |
| 71 | |
| 72 | export async function gscGetOverviewCore(input: { |
| 73 | projectId: string; |
| 74 | startDate: string; |
| 75 | endDate: string; |
| 76 | interval?: 'day' | 'week' | 'month'; |
| 77 | }) { |
| 78 | const data = await getGscOverview( |
| 79 | input.projectId, |
| 80 | input.startDate, |
| 81 | input.endDate, |
| 82 | input.interval ?? 'day', |
| 83 | ); |
| 84 | return { |
| 85 | data, |
| 86 | summary: { |
| 87 | total_clicks: data.reduce((s, r) => s + r.clicks, 0), |
| 88 | total_impressions: data.reduce((s, r) => s + r.impressions, 0), |
| 89 | avg_ctr: |
| 90 | data.length > 0 |
| 91 | ? Math.round( |
| 92 | (data.reduce((s, r) => s + r.ctr, 0) / data.length) * 10000, |
| 93 | ) / 100 |
| 94 | : 0, |
| 95 | avg_position: |
| 96 | data.length > 0 |
| 97 | ? Math.round( |
| 98 | (data.reduce((s, r) => s + r.position, 0) / data.length) * 10, |
| 99 | ) / 10 |
| 100 | : 0, |
| 101 | }, |
| 102 | }; |
| 103 | } |
| 104 | |
| 105 | export async function gscGetTopPagesCore(input: { |
| 106 | projectId: string; |
no test coverage detected