MCPcopy Index your code
hub / github.com/Linen-dev/linen.dev / runSample

Function runSample

packages/seo-stats/src/index.ts:38–78  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

36const lastWeek = new Date(today.getTime() - oneWeek);
37
38async function runSample() {
39 const list = await searchconsole.sites.list();
40 // console.log('%j', list.data.siteEntry);
41
42 const all: any = [];
43 if (list.data.siteEntry) {
44 for (const site of list.data.siteEntry) {
45 if (site.siteUrl) {
46 const result = await searchconsole.searchanalytics
47 .query({
48 requestBody: {
49 // dimensions: ['date'],
50 // dimensions: ['page'], // top pages
51 startDate: lastWeek.toISOString().substring(0, 10),
52 endDate: today.toISOString().substring(0, 10),
53 },
54 siteUrl: site.siteUrl,
55 })
56 .catch((e) => {
57 console.error(e);
58 });
59 if (result) {
60 const info = {
61 site: site.siteUrl,
62 ...result.data.rows?.pop(),
63 };
64 console.log(info);
65 all.push(info);
66 }
67 }
68 }
69 }
70
71 console.log(
72 JSON.stringify(
73 all.sort((a: any, b: any) => b.clicks - a.clicks),
74 null,
75 2
76 )
77 );
78}

Callers 1

index.tsFile · 0.85

Calls 3

listMethod · 0.80
errorMethod · 0.65
logMethod · 0.65

Tested by

no test coverage detected