@nitpicker/report-google-sheets 0.21.0 → 0.22.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/data/create-image-list.d.ts +9 -3
- package/lib/data/create-image-list.js +58 -48
- package/lib/data/create-links.d.ts +11 -3
- package/lib/data/create-links.js +103 -93
- package/lib/data/create-page-list.d.ts +16 -3
- package/lib/data/create-page-list.js +379 -339
- package/lib/data/create-violations.d.ts +9 -3
- package/lib/data/create-violations.js +46 -36
- package/lib/report-google-sheets.d.ts +2 -1
- package/lib/report-google-sheets.js +1 -1
- package/lib/report.d.ts +45 -0
- package/lib/report.js +62 -9
- package/lib/sheets/create-sheets.d.ts +11 -2
- package/lib/sheets/create-sheets.js +19 -2
- package/lib/test-helpers/create-mock-sheet.js +7 -0
- package/package.json +8 -8
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { tryParseUrl as parseUrl } from '@d-zero/shared/parse-url';
|
|
2
|
-
import { buildRedirectFromUrlsByDestId,
|
|
2
|
+
import { buildRedirectFromUrlsByDestId, countPageListRows, getOutboundLinkFactsByPageIds, streamPageListRows, } from '@nitpicker/query';
|
|
3
3
|
import { pLog, reportLog } from '../debug.js';
|
|
4
4
|
import { createCellData } from '../sheets/create-cell-data.js';
|
|
5
5
|
import { defaultCellFormat } from '../sheets/default-cell-format.js';
|
|
@@ -53,356 +53,396 @@ const log = pLog.extend('PageList');
|
|
|
53
53
|
* precomputed once, for every page, before the read model is queryable at
|
|
54
54
|
* all (see `build-viewer-read-model.ts`), so every column is known
|
|
55
55
|
* synchronously from the current row alone.
|
|
56
|
-
*
|
|
57
|
-
*
|
|
56
|
+
* ## URL-restricted mode (`--urls`)
|
|
57
|
+
*
|
|
58
|
+
* `options.urls` (already normalized via `resolvePageListUrlFilter`)
|
|
59
|
+
* restricts every read below to exactly those pages — both
|
|
60
|
+
* `estimateRowCount` and `run` go through `countPageListRows`/
|
|
61
|
+
* `streamPageListRows`, the same shared filter (`applyPageListRowFilters`)
|
|
62
|
+
* that guarantees the two never disagree about which pages are in scope.
|
|
63
|
+
* @param options - Row-set restriction. Omitted or `urls: undefined` reports every page.
|
|
64
|
+
* @param options.urls - See "URL-restricted mode" above.
|
|
65
|
+
* @returns A {@link CreateSheet} factory for the Page List sheet.
|
|
66
|
+
* @example
|
|
67
|
+
* createSheetList.push(createPageList());
|
|
68
|
+
* createSheetList.push(createPageList({ urls: ['https://example.com/a'] }));
|
|
58
69
|
*/
|
|
59
|
-
export
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
},
|
|
138
|
-
estimateRowCount() {
|
|
139
|
-
return countViewerPagesTotal(accessor.getKnex(), { isExternal: false });
|
|
140
|
-
},
|
|
141
|
-
async run({ sheet, maxRows, estimatedTotal, onProgress }) {
|
|
142
|
-
const redirectFromByDestId = await buildRedirectFromUrlsByDestId(accessor);
|
|
143
|
-
let sent = 0;
|
|
144
|
-
const total = estimatedTotal;
|
|
145
|
-
for await (const chunk of streamPageListRows(accessor)) {
|
|
146
|
-
const linkFactsByPageId = await getOutboundLinkFactsByPageIds(accessor, chunk.map((item) => item.pageId));
|
|
147
|
-
for (const item of chunk) {
|
|
148
|
-
if (sent >= maxRows) {
|
|
149
|
-
await sheet.flush();
|
|
150
|
-
return;
|
|
70
|
+
export function createPageList(options) {
|
|
71
|
+
const urls = options?.urls;
|
|
72
|
+
return (reports, accessor) => {
|
|
73
|
+
let maxDepth = 0;
|
|
74
|
+
const reportPageData = reports
|
|
75
|
+
.map((r) => (r.pageData ? { name: r.name, pageData: r.pageData } : null))
|
|
76
|
+
.filter(nonNullFilter);
|
|
77
|
+
return {
|
|
78
|
+
name: 'Page List',
|
|
79
|
+
requiresReadModel: true,
|
|
80
|
+
createHeaders() {
|
|
81
|
+
const headers = [
|
|
82
|
+
'Title',
|
|
83
|
+
'Full Title',
|
|
84
|
+
'URL',
|
|
85
|
+
'Protocol',
|
|
86
|
+
'Domain',
|
|
87
|
+
'path1',
|
|
88
|
+
'path2',
|
|
89
|
+
'path3',
|
|
90
|
+
'path4',
|
|
91
|
+
'path5',
|
|
92
|
+
'path6',
|
|
93
|
+
'path7',
|
|
94
|
+
'path8',
|
|
95
|
+
'path9',
|
|
96
|
+
'path10',
|
|
97
|
+
'Status Code',
|
|
98
|
+
'Redirect From',
|
|
99
|
+
'Redirect To',
|
|
100
|
+
'Language',
|
|
101
|
+
'charset',
|
|
102
|
+
'Internal Links',
|
|
103
|
+
'Internal Bad Links',
|
|
104
|
+
'External Links',
|
|
105
|
+
'External Bad Links',
|
|
106
|
+
'Internal Referrers',
|
|
107
|
+
'description',
|
|
108
|
+
'keywords',
|
|
109
|
+
'noindex',
|
|
110
|
+
'nofollow',
|
|
111
|
+
'noarchive',
|
|
112
|
+
'robots:raw',
|
|
113
|
+
'canonical',
|
|
114
|
+
'manifest',
|
|
115
|
+
'theme-color',
|
|
116
|
+
'twitter:card',
|
|
117
|
+
'twitter:site',
|
|
118
|
+
'twitter:creator',
|
|
119
|
+
'og:site_name',
|
|
120
|
+
'og:url',
|
|
121
|
+
'og:title',
|
|
122
|
+
'og:description',
|
|
123
|
+
'og:type',
|
|
124
|
+
'og:image',
|
|
125
|
+
'og:image:alt',
|
|
126
|
+
'og:locale',
|
|
127
|
+
'og:article:published_time',
|
|
128
|
+
'jsonld_count',
|
|
129
|
+
'tags_providers',
|
|
130
|
+
'main_content_selector',
|
|
131
|
+
'main_content_word_count',
|
|
132
|
+
'main_content_body_word_count',
|
|
133
|
+
'main_content_heading_count',
|
|
134
|
+
'main_content_image_count',
|
|
135
|
+
'main_content_table_count',
|
|
136
|
+
'main_content_button_count',
|
|
137
|
+
'main_content_iframe_count',
|
|
138
|
+
'main_content_video_count',
|
|
139
|
+
'main_content_audio_count',
|
|
140
|
+
'main_content_canvas_count',
|
|
141
|
+
'main_content_custom_element_count',
|
|
142
|
+
'scroll_height_desktop',
|
|
143
|
+
'scroll_height_mobile',
|
|
144
|
+
];
|
|
145
|
+
for (const report of reports) {
|
|
146
|
+
if (report.pageData) {
|
|
147
|
+
headers.push(...Object.values(report.pageData.headers));
|
|
151
148
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
const
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
createCellData({ value: item.url, textFormat: { link: { uri: item.url } } }, defaultCellFormat),
|
|
175
|
-
createCellData({ value: item.protocol }, defaultCellFormat),
|
|
176
|
-
createCellData({ value: item.hostname }, defaultCellFormat),
|
|
177
|
-
createCellData({ value: item.path1 }, defaultCellFormat),
|
|
178
|
-
createCellData({ value: item.path2 }, defaultCellFormat),
|
|
179
|
-
createCellData({ value: item.path3 }, defaultCellFormat),
|
|
180
|
-
createCellData({ value: item.path4 }, defaultCellFormat),
|
|
181
|
-
createCellData({ value: item.path5 }, defaultCellFormat),
|
|
182
|
-
createCellData({ value: item.path6 }, defaultCellFormat),
|
|
183
|
-
createCellData({ value: item.path7 }, defaultCellFormat),
|
|
184
|
-
createCellData({ value: item.path8 }, defaultCellFormat),
|
|
185
|
-
createCellData({ value: item.path9 }, defaultCellFormat),
|
|
186
|
-
createCellData({ value: item.path10 }, defaultCellFormat),
|
|
187
|
-
createCellData({ value: item.status ?? -1 }, defaultCellFormat),
|
|
188
|
-
createCellData({
|
|
189
|
-
value: redirectFromUrls.length,
|
|
190
|
-
note: joinUrlsForNote(redirectFromUrls),
|
|
191
|
-
}, defaultCellFormat),
|
|
192
|
-
createCellData({ value: item.lang || 'N/A' }, defaultCellFormat),
|
|
193
|
-
createCellData({ value: item.charset }, defaultCellFormat),
|
|
194
|
-
createCellData({ value: facts?.internalLinks ?? 0 }, defaultCellFormat),
|
|
195
|
-
createCellData({ value: facts?.internalBadLinks ?? 0 }, defaultCellFormat),
|
|
196
|
-
createCellData({ value: facts?.externalLinks ?? 0 }, defaultCellFormat),
|
|
197
|
-
createCellData({ value: facts?.externalBadLinks ?? 0 }, defaultCellFormat),
|
|
198
|
-
createCellData({ value: internalReferrers }, defaultCellFormat),
|
|
199
|
-
createCellData({ value: item.description }, defaultCellFormat),
|
|
200
|
-
createCellData({ value: item.keywords }, defaultCellFormat),
|
|
201
|
-
createCellData({ value: item.noindex }, defaultCellFormat),
|
|
202
|
-
createCellData({ value: item.nofollow }, defaultCellFormat),
|
|
203
|
-
createCellData({ value: item.noarchive }, defaultCellFormat),
|
|
204
|
-
createCellData({ value: item.robotsRaw }, defaultCellFormat),
|
|
205
|
-
createCellData({ value: item.canonical }, defaultCellFormat),
|
|
206
|
-
createCellData({ value: item.manifest }, defaultCellFormat),
|
|
207
|
-
createCellData({ value: item.themeColor }, defaultCellFormat),
|
|
208
|
-
createCellData({ value: item.twitterCard }, defaultCellFormat),
|
|
209
|
-
createCellData({ value: item.twitterSite }, defaultCellFormat),
|
|
210
|
-
createCellData({ value: item.twitterCreator }, defaultCellFormat),
|
|
211
|
-
createCellData({ value: item.ogSiteName }, defaultCellFormat),
|
|
212
|
-
createCellData({ value: item.ogUrl, textFormat: { link: { uri: item.ogUrl ?? '' } } }, defaultCellFormat),
|
|
213
|
-
createCellData({ value: item.ogTitle }, defaultCellFormat),
|
|
214
|
-
createCellData({ value: item.ogDescription }, defaultCellFormat),
|
|
215
|
-
createCellData({ value: item.ogType }, defaultCellFormat),
|
|
216
|
-
createCellData({ value: item.ogImage }, defaultCellFormat),
|
|
217
|
-
createCellData({ value: item.ogImageAlt }, defaultCellFormat),
|
|
218
|
-
createCellData({ value: item.ogLocale }, defaultCellFormat),
|
|
219
|
-
createCellData({ value: item.ogArticlePublishedTime }, defaultCellFormat),
|
|
220
|
-
// Denormalised aggregates: written at scrape time so no per-page
|
|
221
|
-
// GROUP BY is needed here. `tagsProvidersCsv` is comma-separated
|
|
222
|
-
// for native Google Sheets list rendering.
|
|
223
|
-
createCellData({ value: item.jsonldCount }, defaultCellFormat),
|
|
224
|
-
createCellData({ value: item.tagsProvidersCsv }, defaultCellFormat),
|
|
225
|
-
// beholder MainContentsData / ScrollHeightData denormalised
|
|
226
|
-
// aggregates. `null` (page never fully rendered) or `0` (rendered,
|
|
227
|
-
// no main region / no elements of that kind found) render as
|
|
228
|
-
// blank / 0 respectively — no special-casing needed here.
|
|
229
|
-
createCellData({ value: item.mainContentSelector }, defaultCellFormat),
|
|
230
|
-
createCellData({ value: item.mainContentWordCount }, defaultCellFormat),
|
|
231
|
-
createCellData({ value: item.mainContentBodyWordCount }, defaultCellFormat),
|
|
232
|
-
createCellData({ value: item.mainContentHeadingCount }, defaultCellFormat),
|
|
233
|
-
createCellData({ value: item.mainContentImageCount }, defaultCellFormat),
|
|
234
|
-
createCellData({ value: item.mainContentTableCount }, defaultCellFormat),
|
|
235
|
-
createCellData({ value: item.mainContentButtonCount }, defaultCellFormat),
|
|
236
|
-
createCellData({ value: item.mainContentIframeCount }, defaultCellFormat),
|
|
237
|
-
createCellData({ value: item.mainContentVideoCount }, defaultCellFormat),
|
|
238
|
-
createCellData({ value: item.mainContentAudioCount }, defaultCellFormat),
|
|
239
|
-
createCellData({ value: item.mainContentCanvasCount }, defaultCellFormat),
|
|
240
|
-
createCellData({ value: item.mainContentCustomElementCount }, defaultCellFormat),
|
|
241
|
-
createCellData({ value: item.scrollHeightDesktop }, defaultCellFormat),
|
|
242
|
-
createCellData({ value: item.scrollHeightMobile }, defaultCellFormat),
|
|
243
|
-
];
|
|
244
|
-
for (const report of reportPageData) {
|
|
245
|
-
const tableData = report.pageData.data[item.url];
|
|
246
|
-
const options = report.pageData.options
|
|
247
|
-
? report.pageData.options[item.url]
|
|
248
|
-
: null;
|
|
249
|
-
if (!tableData) {
|
|
250
|
-
reportLog("%s did'nt have table of %s", report.name, item.url);
|
|
149
|
+
}
|
|
150
|
+
return headers;
|
|
151
|
+
},
|
|
152
|
+
estimateRowCount() {
|
|
153
|
+
return countPageListRows(accessor, { urls });
|
|
154
|
+
},
|
|
155
|
+
async run({ sheet, maxRows, estimatedTotal, onProgress }) {
|
|
156
|
+
const redirectFromByDestId = await buildRedirectFromUrlsByDestId(accessor);
|
|
157
|
+
let sent = 0;
|
|
158
|
+
const total = estimatedTotal;
|
|
159
|
+
for await (const chunk of streamPageListRows(accessor, { urls })) {
|
|
160
|
+
const linkFactsByPageId = await getOutboundLinkFactsByPageIds(accessor, chunk.map((item) => item.pageId));
|
|
161
|
+
for (const item of chunk) {
|
|
162
|
+
if (sent >= maxRows) {
|
|
163
|
+
await sheet.flush();
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
// Only for the Title column's indentation depth below --
|
|
167
|
+
// protocol/hostname/path1..10 come precomputed from the read
|
|
168
|
+
// model (item.*) and no longer need a per-row parse.
|
|
169
|
+
const parsedForDepth = parseUrl(item.url);
|
|
170
|
+
if (!parsedForDepth) {
|
|
251
171
|
continue;
|
|
252
172
|
}
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
173
|
+
maxDepth = Math.max(parsedForDepth.depth, maxDepth);
|
|
174
|
+
const isRoot = parsedForDepth.dirname == null;
|
|
175
|
+
const depth = isRoot
|
|
176
|
+
? 0
|
|
177
|
+
: parsedForDepth.depth - (parsedForDepth.isIndex ? 1 : 0);
|
|
178
|
+
const facts = linkFactsByPageId.get(item.pageId);
|
|
179
|
+
const redirectFromUrls = redirectFromByDestId.get(item.pageId) ?? [];
|
|
180
|
+
const internalReferrers = item.dirIndexInboundLinkCount ?? item.inboundLinkCount ?? 0;
|
|
181
|
+
// A redirect-source row (see PageListItem.isRedirectSource's docs)
|
|
182
|
+
// carries no audit signal of its own — every column below reads
|
|
183
|
+
// from a sanitized null/0/false rather than real page data.
|
|
184
|
+
// Rendering the raw sanitized value would read as "an empty page";
|
|
185
|
+
// `dash` renders it as `-` instead, so the row reads as explicitly
|
|
186
|
+
// not-applicable. URL / Status Code / Redirect From / Redirect To
|
|
187
|
+
// are excluded — they carry real signal even on a redirect source.
|
|
188
|
+
const dash = (value) => (item.isRedirectSource ? '-' : value);
|
|
189
|
+
const data = [
|
|
190
|
+
createCellData({
|
|
191
|
+
value: dash(item.displayTitle ?? item.title),
|
|
192
|
+
cellFormat: { padding: { left: Math.max(depth, 0) * 20 + 3 } },
|
|
193
|
+
// `item.title` is sanitized to null on a redirect-source row
|
|
194
|
+
// (see `dash`'s comment above) — omit the note entirely
|
|
195
|
+
// there instead of leaking a literal "Full-title:\nnull"
|
|
196
|
+
// string into it.
|
|
197
|
+
note: item.isRedirectSource
|
|
198
|
+
? undefined
|
|
199
|
+
: truncateNoteText(`Full-title:\n${item.title}`),
|
|
200
|
+
}, defaultCellFormat),
|
|
201
|
+
createCellData({ value: dash(item.title) }, defaultCellFormat),
|
|
202
|
+
createCellData({ value: item.url, textFormat: { link: { uri: item.url } } }, defaultCellFormat),
|
|
203
|
+
createCellData({ value: dash(item.protocol) }, defaultCellFormat),
|
|
204
|
+
createCellData({ value: dash(item.hostname) }, defaultCellFormat),
|
|
205
|
+
createCellData({ value: dash(item.path1) }, defaultCellFormat),
|
|
206
|
+
createCellData({ value: dash(item.path2) }, defaultCellFormat),
|
|
207
|
+
createCellData({ value: dash(item.path3) }, defaultCellFormat),
|
|
208
|
+
createCellData({ value: dash(item.path4) }, defaultCellFormat),
|
|
209
|
+
createCellData({ value: dash(item.path5) }, defaultCellFormat),
|
|
210
|
+
createCellData({ value: dash(item.path6) }, defaultCellFormat),
|
|
211
|
+
createCellData({ value: dash(item.path7) }, defaultCellFormat),
|
|
212
|
+
createCellData({ value: dash(item.path8) }, defaultCellFormat),
|
|
213
|
+
createCellData({ value: dash(item.path9) }, defaultCellFormat),
|
|
214
|
+
createCellData({ value: dash(item.path10) }, defaultCellFormat),
|
|
215
|
+
createCellData({ value: item.status ?? -1 }, defaultCellFormat),
|
|
216
|
+
createCellData({
|
|
217
|
+
value: dash(redirectFromUrls.length),
|
|
218
|
+
note: joinUrlsForNote(redirectFromUrls),
|
|
219
|
+
}, defaultCellFormat),
|
|
220
|
+
createCellData({
|
|
221
|
+
value: item.redirectDestUrl,
|
|
222
|
+
textFormat: item.redirectDestUrl
|
|
223
|
+
? { link: { uri: item.redirectDestUrl } }
|
|
224
|
+
: undefined,
|
|
225
|
+
}, defaultCellFormat),
|
|
226
|
+
createCellData({ value: dash(item.lang || 'N/A') }, defaultCellFormat),
|
|
227
|
+
createCellData({ value: dash(item.charset) }, defaultCellFormat),
|
|
228
|
+
createCellData({ value: dash(facts?.internalLinks ?? 0) }, defaultCellFormat),
|
|
229
|
+
createCellData({ value: dash(facts?.internalBadLinks ?? 0) }, defaultCellFormat),
|
|
230
|
+
createCellData({ value: dash(facts?.externalLinks ?? 0) }, defaultCellFormat),
|
|
231
|
+
createCellData({ value: dash(facts?.externalBadLinks ?? 0) }, defaultCellFormat),
|
|
232
|
+
createCellData({ value: dash(internalReferrers) }, defaultCellFormat),
|
|
233
|
+
createCellData({ value: dash(item.description) }, defaultCellFormat),
|
|
234
|
+
createCellData({ value: dash(item.keywords) }, defaultCellFormat),
|
|
235
|
+
createCellData({ value: dash(item.noindex) }, defaultCellFormat),
|
|
236
|
+
createCellData({ value: dash(item.nofollow) }, defaultCellFormat),
|
|
237
|
+
createCellData({ value: dash(item.noarchive) }, defaultCellFormat),
|
|
238
|
+
createCellData({ value: dash(item.robotsRaw) }, defaultCellFormat),
|
|
239
|
+
createCellData({ value: dash(item.canonical) }, defaultCellFormat),
|
|
240
|
+
createCellData({ value: dash(item.manifest) }, defaultCellFormat),
|
|
241
|
+
createCellData({ value: dash(item.themeColor) }, defaultCellFormat),
|
|
242
|
+
createCellData({ value: dash(item.twitterCard) }, defaultCellFormat),
|
|
243
|
+
createCellData({ value: dash(item.twitterSite) }, defaultCellFormat),
|
|
244
|
+
createCellData({ value: dash(item.twitterCreator) }, defaultCellFormat),
|
|
245
|
+
createCellData({ value: dash(item.ogSiteName) }, defaultCellFormat),
|
|
246
|
+
createCellData({
|
|
247
|
+
value: dash(item.ogUrl),
|
|
248
|
+
textFormat: item.isRedirectSource
|
|
249
|
+
? undefined
|
|
250
|
+
: { link: { uri: item.ogUrl ?? '' } },
|
|
251
|
+
}, defaultCellFormat),
|
|
252
|
+
createCellData({ value: dash(item.ogTitle) }, defaultCellFormat),
|
|
253
|
+
createCellData({ value: dash(item.ogDescription) }, defaultCellFormat),
|
|
254
|
+
createCellData({ value: dash(item.ogType) }, defaultCellFormat),
|
|
255
|
+
createCellData({ value: dash(item.ogImage) }, defaultCellFormat),
|
|
256
|
+
createCellData({ value: dash(item.ogImageAlt) }, defaultCellFormat),
|
|
257
|
+
createCellData({ value: dash(item.ogLocale) }, defaultCellFormat),
|
|
258
|
+
createCellData({ value: dash(item.ogArticlePublishedTime) }, defaultCellFormat),
|
|
259
|
+
// Denormalised aggregates: written at scrape time so no per-page
|
|
260
|
+
// GROUP BY is needed here. `tagsProvidersCsv` is comma-separated
|
|
261
|
+
// for native Google Sheets list rendering.
|
|
262
|
+
createCellData({ value: dash(item.jsonldCount) }, defaultCellFormat),
|
|
263
|
+
createCellData({ value: dash(item.tagsProvidersCsv) }, defaultCellFormat),
|
|
264
|
+
// beholder MainContentsData / ScrollHeightData denormalised
|
|
265
|
+
// aggregates. `null` (page never fully rendered) or `0` (rendered,
|
|
266
|
+
// no main region / no elements of that kind found) render as
|
|
267
|
+
// blank / 0 respectively — no special-casing needed here.
|
|
268
|
+
createCellData({ value: dash(item.mainContentSelector) }, defaultCellFormat),
|
|
269
|
+
createCellData({ value: dash(item.mainContentWordCount) }, defaultCellFormat),
|
|
270
|
+
createCellData({ value: dash(item.mainContentBodyWordCount) }, defaultCellFormat),
|
|
271
|
+
createCellData({ value: dash(item.mainContentHeadingCount) }, defaultCellFormat),
|
|
272
|
+
createCellData({ value: dash(item.mainContentImageCount) }, defaultCellFormat),
|
|
273
|
+
createCellData({ value: dash(item.mainContentTableCount) }, defaultCellFormat),
|
|
274
|
+
createCellData({ value: dash(item.mainContentButtonCount) }, defaultCellFormat),
|
|
275
|
+
createCellData({ value: dash(item.mainContentIframeCount) }, defaultCellFormat),
|
|
276
|
+
createCellData({ value: dash(item.mainContentVideoCount) }, defaultCellFormat),
|
|
277
|
+
createCellData({ value: dash(item.mainContentAudioCount) }, defaultCellFormat),
|
|
278
|
+
createCellData({ value: dash(item.mainContentCanvasCount) }, defaultCellFormat),
|
|
279
|
+
createCellData({ value: dash(item.mainContentCustomElementCount) }, defaultCellFormat),
|
|
280
|
+
createCellData({ value: dash(item.scrollHeightDesktop) }, defaultCellFormat),
|
|
281
|
+
createCellData({ value: dash(item.scrollHeightMobile) }, defaultCellFormat),
|
|
282
|
+
];
|
|
283
|
+
for (const report of reportPageData) {
|
|
284
|
+
const tableData = report.pageData.data[item.url];
|
|
285
|
+
const options = report.pageData.options
|
|
286
|
+
? report.pageData.options[item.url]
|
|
287
|
+
: null;
|
|
288
|
+
if (!tableData) {
|
|
289
|
+
reportLog("%s did'nt have table of %s", report.name, item.url);
|
|
290
|
+
continue;
|
|
279
291
|
}
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
292
|
+
reportLog('Add %s to table from %s', item.url, report.name);
|
|
293
|
+
data.push(...Object.keys(report.pageData.headers).map((key) => {
|
|
294
|
+
const option = options ? options[key] || null : null;
|
|
295
|
+
const cellData = tableData[key];
|
|
296
|
+
const format = {};
|
|
297
|
+
let note;
|
|
298
|
+
if (option) {
|
|
299
|
+
if (option.bold) {
|
|
300
|
+
format.bold = !!option.bold;
|
|
301
|
+
}
|
|
302
|
+
if (option.fontFamily != null) {
|
|
303
|
+
format.fontFamily = `${option.fontFamily}`;
|
|
304
|
+
}
|
|
305
|
+
if (option.fontSize != null) {
|
|
306
|
+
format.fontSize = +option.fontSize;
|
|
307
|
+
}
|
|
308
|
+
if (option.italic != null) {
|
|
309
|
+
format.italic = !!option.italic;
|
|
310
|
+
}
|
|
311
|
+
if (option.strike != null) {
|
|
312
|
+
format.strikethrough = !!option.strike;
|
|
313
|
+
}
|
|
314
|
+
if (option.underline != null) {
|
|
315
|
+
format.underline = !!option.underline;
|
|
316
|
+
}
|
|
317
|
+
note = truncateNoteText(cellData?.note || `${option.note || ''}`);
|
|
318
|
+
}
|
|
319
|
+
const value = cellData?.value;
|
|
320
|
+
return createCellData({ value, textFormat: format, note, ifNull: false }, defaultCellFormat);
|
|
321
|
+
}));
|
|
322
|
+
}
|
|
323
|
+
await sheet.appendRow(data);
|
|
324
|
+
sent++;
|
|
325
|
+
onProgress(sent, total);
|
|
283
326
|
}
|
|
284
|
-
await sheet.appendRow(data);
|
|
285
|
-
sent++;
|
|
286
|
-
onProgress(sent, total);
|
|
287
327
|
}
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
328
|
+
await sheet.flush();
|
|
329
|
+
},
|
|
330
|
+
async updateSheet(sheet) {
|
|
331
|
+
await sheet.frozen(1, 1);
|
|
332
|
+
await sheet.conditionalFormat([
|
|
333
|
+
sheet.getColNumByHeaderName('Internal Bad Links'),
|
|
334
|
+
sheet.getColNumByHeaderName('External Bad Links'),
|
|
335
|
+
], {
|
|
336
|
+
booleanRule: {
|
|
337
|
+
condition: {
|
|
338
|
+
type: 'NUMBER_NOT_EQ',
|
|
339
|
+
values: [
|
|
340
|
+
{
|
|
341
|
+
userEnteredValue: '0',
|
|
342
|
+
},
|
|
343
|
+
],
|
|
344
|
+
},
|
|
345
|
+
format: booleanFormatError,
|
|
305
346
|
},
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
347
|
+
});
|
|
348
|
+
await sheet.conditionalFormat([sheet.getColNumByHeaderName('Language')], {
|
|
349
|
+
booleanRule: {
|
|
350
|
+
condition: {
|
|
351
|
+
type: 'TEXT_EQ',
|
|
352
|
+
values: [
|
|
353
|
+
{
|
|
354
|
+
userEnteredValue: 'N/A',
|
|
355
|
+
},
|
|
356
|
+
],
|
|
357
|
+
},
|
|
358
|
+
format: booleanFormatError,
|
|
318
359
|
},
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
360
|
+
});
|
|
361
|
+
await sheet.conditionalFormat([sheet.getColNumByHeaderName('Internal Referrers')], {
|
|
362
|
+
booleanRule: {
|
|
363
|
+
condition: {
|
|
364
|
+
type: 'NUMBER_LESS',
|
|
365
|
+
values: [
|
|
366
|
+
{
|
|
367
|
+
userEnteredValue: '2',
|
|
368
|
+
},
|
|
369
|
+
],
|
|
370
|
+
},
|
|
371
|
+
format: booleanFormatError,
|
|
331
372
|
},
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
373
|
+
});
|
|
374
|
+
await sheet.conditionalFormat([
|
|
375
|
+
sheet.getColNumByHeaderName('path1'),
|
|
376
|
+
sheet.getColNumByHeaderName('path2'),
|
|
377
|
+
sheet.getColNumByHeaderName('path3'),
|
|
378
|
+
sheet.getColNumByHeaderName('path4'),
|
|
379
|
+
sheet.getColNumByHeaderName('path5'),
|
|
380
|
+
sheet.getColNumByHeaderName('path6'),
|
|
381
|
+
sheet.getColNumByHeaderName('path7'),
|
|
382
|
+
sheet.getColNumByHeaderName('path8'),
|
|
383
|
+
sheet.getColNumByHeaderName('path9'),
|
|
384
|
+
sheet.getColNumByHeaderName('path10'),
|
|
385
|
+
], {
|
|
386
|
+
booleanRule: {
|
|
387
|
+
condition: {
|
|
388
|
+
type: 'CUSTOM_FORMULA',
|
|
389
|
+
values: [
|
|
390
|
+
{
|
|
391
|
+
userEnteredValue: '=REGEXMATCH(INDIRECT(ADDRESS(ROW(),COLUMN())), "(?i)(^/_|_$|_copy|-copy|copy_|copy-|dummy)")',
|
|
392
|
+
},
|
|
393
|
+
],
|
|
394
|
+
},
|
|
395
|
+
format: booleanFormatError,
|
|
355
396
|
},
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
397
|
+
});
|
|
398
|
+
await sheet.conditionalFormat([sheet.getColNumByHeaderName('Title')], {
|
|
399
|
+
booleanRule: {
|
|
400
|
+
condition: {
|
|
401
|
+
type: 'CUSTOM_FORMULA',
|
|
402
|
+
values: [
|
|
403
|
+
{
|
|
404
|
+
userEnteredValue: '=REGEXMATCH(INDIRECT(ADDRESS(ROW(),COLUMN())), "(?i)(^| )(401|403|404|500|501|502|503)")',
|
|
405
|
+
},
|
|
406
|
+
],
|
|
407
|
+
},
|
|
408
|
+
format: booleanFormatError,
|
|
368
409
|
},
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
410
|
+
});
|
|
411
|
+
await sheet.conditionalFormat([sheet.getColNumByHeaderName('Protocol')], {
|
|
412
|
+
booleanRule: {
|
|
413
|
+
condition: {
|
|
414
|
+
type: 'TEXT_EQ',
|
|
415
|
+
values: [
|
|
416
|
+
{
|
|
417
|
+
userEnteredValue: 'http:',
|
|
418
|
+
},
|
|
419
|
+
],
|
|
420
|
+
},
|
|
421
|
+
format: booleanFormatError,
|
|
381
422
|
},
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
423
|
+
});
|
|
424
|
+
await sheet.conditionalFormat([sheet.getColNumByHeaderName('Status Code')], {
|
|
425
|
+
booleanRule: {
|
|
426
|
+
condition: {
|
|
427
|
+
type: 'NUMBER_NOT_BETWEEN',
|
|
428
|
+
values: [
|
|
429
|
+
{
|
|
430
|
+
userEnteredValue: '200',
|
|
431
|
+
},
|
|
432
|
+
{
|
|
433
|
+
userEnteredValue: '399',
|
|
434
|
+
},
|
|
435
|
+
],
|
|
436
|
+
},
|
|
437
|
+
format: booleanFormatError,
|
|
397
438
|
},
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
},
|
|
439
|
+
});
|
|
440
|
+
for (let i = maxDepth + 1; i <= 10; i++) {
|
|
441
|
+
const name = `path${i}`;
|
|
442
|
+
log('Hide col %s', name);
|
|
443
|
+
await sheet.hideCol(sheet.getColNumByHeaderName(name));
|
|
444
|
+
}
|
|
445
|
+
},
|
|
446
|
+
};
|
|
407
447
|
};
|
|
408
|
-
}
|
|
448
|
+
}
|