@nitpicker/report-google-sheets 0.19.0 → 0.20.0
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-discrepancies.d.ts +10 -12
- package/lib/data/create-discrepancies.js +27 -31
- package/lib/data/create-image-list.d.ts +26 -6
- package/lib/data/create-image-list.js +65 -39
- package/lib/data/create-links.d.ts +18 -1
- package/lib/data/create-links.js +91 -55
- package/lib/data/create-page-list.d.ts +24 -24
- package/lib/data/create-page-list.js +177 -225
- package/lib/data/create-referrers-relational-table.d.ts +13 -7
- package/lib/data/create-referrers-relational-table.js +57 -47
- package/lib/data/create-resources-relational-table.d.ts +7 -0
- package/lib/data/create-resources-relational-table.js +41 -33
- package/lib/data/create-resources.d.ts +24 -124
- package/lib/data/create-resources.js +100 -264
- package/lib/data/create-violations.d.ts +7 -6
- package/lib/data/create-violations.js +34 -19
- package/lib/dedupe-progress-message.d.ts +17 -0
- package/lib/dedupe-progress-message.js +26 -0
- package/lib/format-progress-count.d.ts +19 -0
- package/lib/format-progress-count.js +22 -0
- package/lib/open-report-archive.d.ts +54 -0
- package/lib/open-report-archive.js +76 -0
- package/lib/report.d.ts +16 -12
- package/lib/report.js +101 -94
- package/lib/reports/get-plugin-reports.d.ts +14 -6
- package/lib/reports/get-plugin-reports.js +14 -34
- package/lib/sheets/create-sheets.d.ts +66 -36
- package/lib/sheets/create-sheets.js +228 -362
- package/lib/sheets/estimate-cell-budget.d.ts +55 -0
- package/lib/sheets/estimate-cell-budget.js +56 -0
- package/lib/sheets/types.d.ts +111 -91
- package/lib/test-helpers/assert-no-lazy-cells.d.ts +16 -0
- package/lib/test-helpers/assert-no-lazy-cells.js +23 -0
- package/lib/test-helpers/cell-inspection.d.ts +20 -0
- package/lib/test-helpers/cell-inspection.js +21 -0
- package/lib/test-helpers/create-mock-sheet.d.ts +30 -0
- package/lib/test-helpers/create-mock-sheet.js +71 -0
- package/lib/test-helpers/one-chunk.d.ts +8 -0
- package/lib/test-helpers/one-chunk.js +11 -0
- package/lib/utils/join-urls-for-note.d.ts +27 -0
- package/lib/utils/join-urls-for-note.js +48 -0
- package/lib/utils/truncate-note-text.d.ts +15 -0
- package/lib/utils/truncate-note-text.js +23 -0
- package/package.json +7 -9
- package/lib/archive.d.ts +0 -29
- package/lib/archive.js +0 -49
- package/lib/sheets/run-finalize-resources.d.ts +0 -40
- package/lib/sheets/run-finalize-resources.js +0 -44
- package/lib/types.d.ts +0 -11
- package/lib/types.js +0 -1
- package/lib/utils/canonicalize-url.d.ts +0 -53
- package/lib/utils/canonicalize-url.js +0 -105
- package/lib/utils/has-prop-filter.d.ts +0 -18
- package/lib/utils/has-prop-filter.js +0 -19
- package/lib/utils/sort-resources-by-url.d.ts +0 -69
- package/lib/utils/sort-resources-by-url.js +0 -223
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { tryParseUrl as parseUrl } from '@d-zero/shared/parse-url';
|
|
2
|
+
import { buildRedirectFromUrlsByDestId, countViewerPagesTotal, getOutboundLinkFactsByPageIds, streamPageListRows, } from '@nitpicker/query';
|
|
2
3
|
import { pLog, reportLog } from '../debug.js';
|
|
3
4
|
import { createCellData } from '../sheets/create-cell-data.js';
|
|
4
5
|
import { defaultCellFormat } from '../sheets/default-cell-format.js';
|
|
5
6
|
import { booleanFormatError } from '../sheets/format.js';
|
|
7
|
+
import { joinUrlsForNote } from '../utils/join-urls-for-note.js';
|
|
6
8
|
import { nonNullFilter } from '../utils/non-null-filter.js';
|
|
9
|
+
import { truncateNoteText } from '../utils/truncate-note-text.js';
|
|
7
10
|
const log = pLog.extend('PageList');
|
|
8
11
|
/**
|
|
9
12
|
* Creates the "Page List" sheet configuration -- the primary sitemap-style report.
|
|
@@ -11,13 +14,16 @@ const log = pLog.extend('PageList');
|
|
|
11
14
|
* This is the most complex sheet, combining crawler metadata with analyze
|
|
12
15
|
* plugin data into a comprehensive per-page inventory:
|
|
13
16
|
*
|
|
14
|
-
* - **URL decomposition**: Protocol, domain, and up to 10 path segments
|
|
15
|
-
*
|
|
17
|
+
* - **URL decomposition**: Protocol, domain, and up to 10 path segments for
|
|
18
|
+
* hierarchical filtering in the spreadsheet — computed once at read-model
|
|
19
|
+
* build time, not per-batch (see `PageListItem.path1`'s docs).
|
|
16
20
|
* - **Title shortening**: Directory index titles are subtracted from child
|
|
17
21
|
* page titles to produce concise display titles (e.g. removing the site
|
|
18
|
-
* name suffix)
|
|
22
|
+
* name suffix) — computed once at read-model build time, not per-batch
|
|
23
|
+
* (see `PageListItem.displayTitle`'s docs).
|
|
19
24
|
* - **Link quality**: Internal/external link counts with bad-link breakdowns
|
|
20
|
-
* (status >= 400, excluding 401 which is often auth-protected)
|
|
25
|
+
* (status >= 400, excluding 401 which is often auth-protected) — fetched
|
|
26
|
+
* per cursor batch via `getOutboundLinkFactsByPageIds`.
|
|
21
27
|
* - **SEO metadata**: description, keywords, canonical, alternate, OGP, etc.
|
|
22
28
|
* - **Plugin columns**: Dynamic columns from analyze plugin `pageData`.
|
|
23
29
|
*
|
|
@@ -31,37 +37,33 @@ const log = pLog.extend('PageList');
|
|
|
31
37
|
*
|
|
32
38
|
* Unused path columns (beyond the deepest URL) are hidden automatically.
|
|
33
39
|
*
|
|
34
|
-
* ##
|
|
40
|
+
* ## Streaming design (report OOM fix)
|
|
35
41
|
*
|
|
36
|
-
*
|
|
37
|
-
* —
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
* `
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
* is needed since the library auto-detects. The corresponding spec
|
|
51
|
-
* (`create-page-list.spec.ts`) asserts the presence of at least one lazy
|
|
52
|
-
* cell so the maintainer who removes the thunk will see the test fail and
|
|
53
|
-
* be prompted to reconsider whether the change is intentional.
|
|
42
|
+
* Reads `streamPageListRows` (a `viewer_pages` keyset sweep,
|
|
43
|
+
* `requiresReadModel: true` — see that function's docs for why it exists
|
|
44
|
+
* instead of reusing the viewer UI's `listViewerPages`) one chunk at a time
|
|
45
|
+
* and sends each row via `sheet.appendRow(...)` immediately — no lazy
|
|
46
|
+
* (`createCellData(() => ...)`) cells anywhere in this file. The pre-rewrite
|
|
47
|
+
* version used a lazy thunk for "Internal Referrers" (its value depended on
|
|
48
|
+
* sibling index pages processed later in the same batch), which disabled
|
|
49
|
+
* `@d-zero/google-sheets`' automatic 2500-row flush for the entire batch —
|
|
50
|
+
* the direct cause of the OOM this rewrite fixes. That cross-page dependency
|
|
51
|
+
* no longer exists: `displayTitle`/`inboundLinkCount`/
|
|
52
|
+
* `dirIndexInboundLinkCount`/`protocol`/`hostname`/`path1`..`path10` are all
|
|
53
|
+
* precomputed once, for every page, before the read model is queryable at
|
|
54
|
+
* all (see `build-viewer-read-model.ts`), so every column is known
|
|
55
|
+
* synchronously from the current row alone.
|
|
54
56
|
* @param reports - Analyze plugin reports to extract per-page data columns from
|
|
57
|
+
* @param accessor - The archive accessor to query.
|
|
55
58
|
*/
|
|
56
|
-
export const createPageList = (reports) => {
|
|
57
|
-
|
|
58
|
-
const indexRefs = new Map();
|
|
59
|
+
export const createPageList = (reports, accessor) => {
|
|
60
|
+
let maxDepth = 0;
|
|
59
61
|
const reportPageData = reports
|
|
60
62
|
.map((r) => (r.pageData ? { name: r.name, pageData: r.pageData } : null))
|
|
61
63
|
.filter(nonNullFilter);
|
|
62
|
-
let maxDepth = 0;
|
|
63
64
|
return {
|
|
64
65
|
name: 'Page List',
|
|
66
|
+
requiresReadModel: true,
|
|
65
67
|
createHeaders() {
|
|
66
68
|
const headers = [
|
|
67
69
|
'Title',
|
|
@@ -133,208 +135,158 @@ export const createPageList = (reports) => {
|
|
|
133
135
|
}
|
|
134
136
|
return headers;
|
|
135
137
|
},
|
|
136
|
-
async
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
const
|
|
141
|
-
|
|
142
|
-
const
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
const xBadLinks = [];
|
|
150
|
-
for (const anchor of anchors) {
|
|
151
|
-
if (anchor.isExternal) {
|
|
152
|
-
xLinks += 1;
|
|
153
|
-
if (!anchor.status || (anchor.status >= 400 && anchor.status !== 401)) {
|
|
154
|
-
const url = anchor.href === anchor.url ? anchor.url : `${anchor.href} => ${anchor.url}`;
|
|
155
|
-
xBadLinks.push(`${anchor.textContent} (${anchor.status} ${anchor.statusText} ${url})`);
|
|
138
|
+
async 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;
|
|
156
151
|
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
152
|
+
// Only for the Title column's indentation depth below --
|
|
153
|
+
// protocol/hostname/path1..10 come precomputed from the read
|
|
154
|
+
// model (item.*) and no longer need a per-row parse.
|
|
155
|
+
const parsedForDepth = parseUrl(item.url);
|
|
156
|
+
if (!parsedForDepth) {
|
|
157
|
+
continue;
|
|
163
158
|
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
{
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
:
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
:
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
createCellData({ value: page.metaFlat.twitter_creator }, defaultCellFormat),
|
|
258
|
-
createCellData({ value: page.og_site_name }, defaultCellFormat),
|
|
259
|
-
createCellData({
|
|
260
|
-
value: page.og_url,
|
|
261
|
-
textFormat: { link: { uri: page.og_url } },
|
|
262
|
-
}, defaultCellFormat),
|
|
263
|
-
createCellData({ value: page.og_title }, defaultCellFormat),
|
|
264
|
-
createCellData({ value: page.og_description }, defaultCellFormat),
|
|
265
|
-
createCellData({ value: page.og_type }, defaultCellFormat),
|
|
266
|
-
createCellData({ value: page.og_image }, defaultCellFormat),
|
|
267
|
-
createCellData({ value: page.metaFlat.og_image_alt }, defaultCellFormat),
|
|
268
|
-
createCellData({ value: page.metaFlat.og_locale }, defaultCellFormat),
|
|
269
|
-
createCellData({ value: page.metaFlat.og_article_published_time }, defaultCellFormat),
|
|
270
|
-
// Denormalised aggregates: written at scrape time so no per-page
|
|
271
|
-
// GROUP BY is needed here. `tagsProvidersCsv` is comma-separated
|
|
272
|
-
// for native Google Sheets list rendering.
|
|
273
|
-
createCellData({ value: page.jsonldCount }, defaultCellFormat),
|
|
274
|
-
createCellData({ value: page.tagsProvidersCsv }, defaultCellFormat),
|
|
275
|
-
// beholder MainContentsData / ScrollHeightData denormalised
|
|
276
|
-
// aggregates. `null` (page never fully rendered) or `0` (rendered,
|
|
277
|
-
// no main region / no elements of that kind found) render as
|
|
278
|
-
// blank / 0 respectively — no special-casing needed here.
|
|
279
|
-
createCellData({ value: page.mainContentSelector }, defaultCellFormat),
|
|
280
|
-
createCellData({ value: page.mainContentWordCount }, defaultCellFormat),
|
|
281
|
-
createCellData({ value: page.mainContentBodyWordCount }, defaultCellFormat),
|
|
282
|
-
createCellData({ value: page.mainContentHeadingCount }, defaultCellFormat),
|
|
283
|
-
createCellData({ value: page.mainContentImageCount }, defaultCellFormat),
|
|
284
|
-
createCellData({ value: page.mainContentTableCount }, defaultCellFormat),
|
|
285
|
-
createCellData({ value: page.mainContentButtonCount }, defaultCellFormat),
|
|
286
|
-
createCellData({ value: page.mainContentIframeCount }, defaultCellFormat),
|
|
287
|
-
createCellData({ value: page.mainContentVideoCount }, defaultCellFormat),
|
|
288
|
-
createCellData({ value: page.mainContentAudioCount }, defaultCellFormat),
|
|
289
|
-
createCellData({ value: page.mainContentCanvasCount }, defaultCellFormat),
|
|
290
|
-
createCellData({ value: page.mainContentCustomElementCount }, defaultCellFormat),
|
|
291
|
-
createCellData({ value: page.scrollHeightDesktop }, defaultCellFormat),
|
|
292
|
-
createCellData({ value: page.scrollHeightMobile }, defaultCellFormat),
|
|
293
|
-
];
|
|
294
|
-
for (const report of reportPageData) {
|
|
295
|
-
const tableData = report.pageData.data[page.url.href];
|
|
296
|
-
const options = report.pageData.options
|
|
297
|
-
? report.pageData.options[page.url.href]
|
|
298
|
-
: null;
|
|
299
|
-
if (!tableData) {
|
|
300
|
-
reportLog("%s did'nt have table of %s", report.name, page.url);
|
|
301
|
-
continue;
|
|
302
|
-
}
|
|
303
|
-
reportLog('Add %s to table from %s', page.url.href, report.name);
|
|
304
|
-
data.push(...Object.keys(report.pageData.headers).map((key) => {
|
|
305
|
-
const option = options ? options[key] || null : null;
|
|
306
|
-
const data = tableData[key];
|
|
307
|
-
const format = {};
|
|
308
|
-
let note;
|
|
309
|
-
if (option) {
|
|
310
|
-
if (option.bold) {
|
|
311
|
-
format.bold = !!option.bold;
|
|
312
|
-
}
|
|
313
|
-
if (option.fontFamily != null) {
|
|
314
|
-
format.fontFamily = `${option.fontFamily}`;
|
|
315
|
-
}
|
|
316
|
-
if (option.fontSize != null) {
|
|
317
|
-
format.fontSize = +option.fontSize;
|
|
159
|
+
maxDepth = Math.max(parsedForDepth.depth, maxDepth);
|
|
160
|
+
const isRoot = parsedForDepth.dirname == null;
|
|
161
|
+
const depth = isRoot
|
|
162
|
+
? 0
|
|
163
|
+
: parsedForDepth.depth - (parsedForDepth.isIndex ? 1 : 0);
|
|
164
|
+
const facts = linkFactsByPageId.get(item.pageId);
|
|
165
|
+
const redirectFromUrls = redirectFromByDestId.get(item.pageId) ?? [];
|
|
166
|
+
const internalReferrers = item.dirIndexInboundLinkCount ?? item.inboundLinkCount ?? 0;
|
|
167
|
+
const data = [
|
|
168
|
+
createCellData({
|
|
169
|
+
value: item.displayTitle ?? item.title,
|
|
170
|
+
cellFormat: { padding: { left: Math.max(depth, 0) * 20 + 3 } },
|
|
171
|
+
note: truncateNoteText(`Full-title:\n${item.title}`),
|
|
172
|
+
}, defaultCellFormat),
|
|
173
|
+
createCellData({ value: item.title }, defaultCellFormat),
|
|
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);
|
|
251
|
+
continue;
|
|
318
252
|
}
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
format
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
253
|
+
reportLog('Add %s to table from %s', item.url, report.name);
|
|
254
|
+
data.push(...Object.keys(report.pageData.headers).map((key) => {
|
|
255
|
+
const option = options ? options[key] || null : null;
|
|
256
|
+
const cellData = tableData[key];
|
|
257
|
+
const format = {};
|
|
258
|
+
let note;
|
|
259
|
+
if (option) {
|
|
260
|
+
if (option.bold) {
|
|
261
|
+
format.bold = !!option.bold;
|
|
262
|
+
}
|
|
263
|
+
if (option.fontFamily != null) {
|
|
264
|
+
format.fontFamily = `${option.fontFamily}`;
|
|
265
|
+
}
|
|
266
|
+
if (option.fontSize != null) {
|
|
267
|
+
format.fontSize = +option.fontSize;
|
|
268
|
+
}
|
|
269
|
+
if (option.italic != null) {
|
|
270
|
+
format.italic = !!option.italic;
|
|
271
|
+
}
|
|
272
|
+
if (option.strike != null) {
|
|
273
|
+
format.strikethrough = !!option.strike;
|
|
274
|
+
}
|
|
275
|
+
if (option.underline != null) {
|
|
276
|
+
format.underline = !!option.underline;
|
|
277
|
+
}
|
|
278
|
+
note = truncateNoteText(cellData?.note || `${option.note || ''}`);
|
|
279
|
+
}
|
|
280
|
+
const value = cellData?.value;
|
|
281
|
+
return createCellData({ value, textFormat: format, note, ifNull: false }, defaultCellFormat);
|
|
282
|
+
}));
|
|
332
283
|
}
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
284
|
+
await sheet.appendRow(data);
|
|
285
|
+
sent++;
|
|
286
|
+
onProgress(sent, total);
|
|
287
|
+
}
|
|
336
288
|
}
|
|
337
|
-
|
|
289
|
+
await sheet.flush();
|
|
338
290
|
},
|
|
339
291
|
async updateSheet(sheet) {
|
|
340
292
|
await sheet.frozen(1, 1);
|
|
@@ -2,17 +2,23 @@ import type { CreateSheet } from '../sheets/types.js';
|
|
|
2
2
|
/**
|
|
3
3
|
* Creates the "Referrers Relational Table" sheet configuration.
|
|
4
4
|
*
|
|
5
|
-
* Produces a normalized many-to-many table linking each page to
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
5
|
+
* Produces a normalized many-to-many table linking each page to the pages
|
|
6
|
+
* that reference it (referrers). Each row is one `viewer_anchor_facts`
|
|
7
|
+
* edge — a unique `(source, resolved destination)` pair, with an
|
|
8
|
+
* occurrence `Count` column, plus the destination's HTTP status info.
|
|
9
9
|
*
|
|
10
10
|
* This relational format (as opposed to the denormalized referrer
|
|
11
11
|
* column in "Links") enables pivot-table analysis and filtering
|
|
12
12
|
* in Google Sheets -- e.g. "which pages link to this 404 page?"
|
|
13
13
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
14
|
+
* One row per edge (not per raw anchor observation): the redirect/alias
|
|
15
|
+
* resolution that collapses multiple raw anchors into one edge means a
|
|
16
|
+
* per-anchor "redirected from" note is no longer meaningful at this grain
|
|
17
|
+
* for every raw occurrence — but the edge's own raw href (before
|
|
18
|
+
* resolution) is still shown as a note on the "Link (To)" cell whenever it
|
|
19
|
+
* differs from the resolved destination, and the `Count` column reports how
|
|
20
|
+
* many raw anchor occurrences this edge summarizes.
|
|
21
|
+
* @param _reports
|
|
22
|
+
* @param accessor
|
|
17
23
|
*/
|
|
18
24
|
export declare const createReferrersRelationalTable: CreateSheet;
|