@nitpicker/crawler 0.22.0 → 0.23.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/archive/archive.d.ts +13 -5
- package/lib/archive/archive.js +13 -5
- package/lib/archive/cache/extract-archive-to-cache.d.ts +6 -1
- package/lib/archive/cache/extract-archive-to-cache.js +13 -6
- package/lib/archive/create-adjunct-tables.d.ts +0 -7
- package/lib/archive/create-adjunct-tables.js +0 -50
- package/lib/archive/create-template-tables.d.ts +30 -0
- package/lib/archive/create-template-tables.js +95 -0
- package/lib/archive/database.d.ts +1 -1
- package/lib/archive/database.js +1 -1
- package/lib/archive/db-ops/pages/read/get-crawling-state.d.ts +43 -3
- package/lib/archive/db-ops/pages/read/get-crawling-state.js +61 -6
- package/lib/archive/db-ops/pages/write/update-page.js +10 -2
- package/lib/archive/db-ops/templates/assign-template-labels.d.ts +60 -0
- package/lib/archive/db-ops/templates/assign-template-labels.js +187 -0
- package/lib/archive/db-ops/{analysis → templates}/replace-page-templates.d.ts +19 -3
- package/lib/archive/db-ops/templates/replace-page-templates.js +174 -0
- package/lib/archive/db-ops/{analysis → templates}/types.d.ts +38 -0
- package/lib/archive/init-schema.d.ts +5 -1
- package/lib/archive/init-schema.js +13 -2
- package/lib/archive/test-utils/build-full-schema-test-db.d.ts +34 -0
- package/lib/archive/test-utils/build-full-schema-test-db.js +74 -0
- package/lib/archive/transfer/attach-source-database.d.ts +31 -0
- package/lib/archive/transfer/attach-source-database.js +40 -0
- package/lib/archive/transfer/build-split-config.d.ts +30 -0
- package/lib/archive/transfer/build-split-config.js +42 -0
- package/lib/archive/transfer/clear-replaced-page-rows.d.ts +20 -0
- package/lib/archive/transfer/clear-replaced-page-rows.js +57 -0
- package/lib/archive/transfer/concat-archives.d.ts +55 -0
- package/lib/archive/transfer/concat-archives.js +95 -0
- package/lib/archive/transfer/content-item-rank-sql.d.ts +21 -0
- package/lib/archive/transfer/content-item-rank-sql.js +23 -0
- package/lib/archive/transfer/copy-analysis-violations.d.ts +19 -0
- package/lib/archive/transfer/copy-analysis-violations.js +43 -0
- package/lib/archive/transfer/copy-anchor-edges.d.ts +28 -0
- package/lib/archive/transfer/copy-anchor-edges.js +42 -0
- package/lib/archive/transfer/copy-dictionaries-for-concat.d.ts +39 -0
- package/lib/archive/transfer/copy-dictionaries-for-concat.js +81 -0
- package/lib/archive/transfer/copy-dictionaries-for-split.d.ts +29 -0
- package/lib/archive/transfer/copy-dictionaries-for-split.js +235 -0
- package/lib/archive/transfer/copy-header-set-children.d.ts +27 -0
- package/lib/archive/transfer/copy-header-set-children.js +51 -0
- package/lib/archive/transfer/copy-image-items.d.ts +21 -0
- package/lib/archive/transfer/copy-image-items.js +62 -0
- package/lib/archive/transfer/copy-inventory-source-lists.d.ts +30 -0
- package/lib/archive/transfer/copy-inventory-source-lists.js +61 -0
- package/lib/archive/transfer/copy-journal-tables.d.ts +30 -0
- package/lib/archive/transfer/copy-journal-tables.js +56 -0
- package/lib/archive/transfer/copy-page-console-logs.d.ts +16 -0
- package/lib/archive/transfer/copy-page-console-logs.js +27 -0
- package/lib/archive/transfer/copy-page-html-blobs.d.ts +31 -0
- package/lib/archive/transfer/copy-page-html-blobs.js +43 -0
- package/lib/archive/transfer/copy-page-meta.d.ts +27 -0
- package/lib/archive/transfer/copy-page-meta.js +68 -0
- package/lib/archive/transfer/copy-page-template-clusters.d.ts +31 -0
- package/lib/archive/transfer/copy-page-template-clusters.js +56 -0
- package/lib/archive/transfer/copy-page-template-labels.d.ts +34 -0
- package/lib/archive/transfer/copy-page-template-labels.js +88 -0
- package/lib/archive/transfer/copy-resource-items.d.ts +29 -0
- package/lib/archive/transfer/copy-resource-items.js +89 -0
- package/lib/archive/transfer/copy-resource-ref-edges.d.ts +20 -0
- package/lib/archive/transfer/copy-resource-ref-edges.js +33 -0
- package/lib/archive/transfer/copy-simple-page-scoped-tables.d.ts +15 -0
- package/lib/archive/transfer/copy-simple-page-scoped-tables.js +34 -0
- package/lib/archive/transfer/count-external-pages-in-scope.d.ts +26 -0
- package/lib/archive/transfer/count-external-pages-in-scope.js +40 -0
- package/lib/archive/transfer/create-transfer-temp-tables.d.ts +30 -0
- package/lib/archive/transfer/create-transfer-temp-tables.js +59 -0
- package/lib/archive/transfer/dictionary-copy-specs.d.ts +32 -0
- package/lib/archive/transfer/dictionary-copy-specs.js +29 -0
- package/lib/archive/transfer/drop-transfer-temp-tables.d.ts +9 -0
- package/lib/archive/transfer/drop-transfer-temp-tables.js +18 -0
- package/lib/archive/transfer/flatten-redirect-chains.d.ts +44 -0
- package/lib/archive/transfer/flatten-redirect-chains.js +74 -0
- package/lib/archive/transfer/insert-content-items.d.ts +35 -0
- package/lib/archive/transfer/insert-content-items.js +116 -0
- package/lib/archive/transfer/list-transfer-columns.d.ts +35 -0
- package/lib/archive/transfer/list-transfer-columns.js +45 -0
- package/lib/archive/transfer/mark-in-scope-content-items.d.ts +31 -0
- package/lib/archive/transfer/mark-in-scope-content-items.js +54 -0
- package/lib/archive/transfer/merge-archive-configs.d.ts +48 -0
- package/lib/archive/transfer/merge-archive-configs.js +78 -0
- package/lib/archive/transfer/plan-content-items-for-concat.d.ts +33 -0
- package/lib/archive/transfer/plan-content-items-for-concat.js +51 -0
- package/lib/archive/transfer/plan-content-items-for-split.d.ts +42 -0
- package/lib/archive/transfer/plan-content-items-for-split.js +83 -0
- package/lib/archive/transfer/plan-resource-items.d.ts +40 -0
- package/lib/archive/transfer/plan-resource-items.js +69 -0
- package/lib/archive/transfer/quote-transfer-identifier.d.ts +18 -0
- package/lib/archive/transfer/quote-transfer-identifier.js +20 -0
- package/lib/archive/transfer/reclassify-resource-externality.d.ts +37 -0
- package/lib/archive/transfer/reclassify-resource-externality.js +66 -0
- package/lib/archive/transfer/remap-redirect-dest-ids.d.ts +34 -0
- package/lib/archive/transfer/remap-redirect-dest-ids.js +51 -0
- package/lib/archive/transfer/replace-content-items.d.ts +39 -0
- package/lib/archive/transfer/replace-content-items.js +83 -0
- package/lib/archive/transfer/simple-page-scoped-tables.d.ts +25 -0
- package/lib/archive/transfer/simple-page-scoped-tables.js +38 -0
- package/lib/archive/transfer/split-archive.d.ts +55 -0
- package/lib/archive/transfer/split-archive.js +98 -0
- package/lib/archive/transfer/transfer-action.d.ts +34 -0
- package/lib/archive/transfer/transfer-action.js +32 -0
- package/lib/archive/transfer/transfer-archive-rows.d.ts +65 -0
- package/lib/archive/transfer/transfer-archive-rows.js +158 -0
- package/lib/archive/transfer/transfer-dictionary-tables.d.ts +12 -0
- package/lib/archive/transfer/transfer-dictionary-tables.js +23 -0
- package/lib/archive/transfer/transfer-source-alias.d.ts +9 -0
- package/lib/archive/transfer/transfer-source-alias.js +9 -0
- package/lib/archive/transfer/types.d.ts +111 -0
- package/lib/archive/transfer/types.js +35 -0
- package/lib/concat-source-transfer-phases.d.ts +10 -0
- package/lib/concat-source-transfer-phases.js +17 -0
- package/lib/crawler/build-scope-map.d.ts +21 -0
- package/lib/crawler/build-scope-map.js +32 -0
- package/lib/crawler-orchestrator.js +10 -16
- package/lib/crawler.d.ts +13 -1
- package/lib/crawler.js +22 -0
- package/lib/split-source-transfer-phases.d.ts +11 -0
- package/lib/split-source-transfer-phases.js +18 -0
- package/lib/template-classification/classify-archive-page-templates.d.ts +41 -0
- package/lib/template-classification/classify-archive-page-templates.js +79 -0
- package/lib/template-classification/classify-page-templates.d.ts +37 -0
- package/lib/template-classification/classify-page-templates.js +69 -0
- package/lib/template-classification/collect-page-stylesheet-urls.d.ts +32 -0
- package/lib/template-classification/collect-page-stylesheet-urls.js +130 -0
- package/lib/template-classification/create-content-root-hint.d.ts +36 -0
- package/lib/template-classification/create-content-root-hint.js +47 -0
- package/lib/template-classification/create-page-cluster-factory.d.ts +60 -0
- package/lib/template-classification/create-page-cluster-factory.js +98 -0
- package/lib/template-classification/types.d.ts +108 -0
- package/lib/template-classification/types.js +1 -0
- package/lib/transfer-post-phases.d.ts +10 -0
- package/lib/transfer-post-phases.js +13 -0
- package/package.json +3 -2
- package/lib/archive/db-ops/analysis/replace-page-templates.js +0 -84
- /package/lib/archive/db-ops/{analysis → templates}/types.js +0 -0
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import type Archive from '../archive/archive.js';
|
|
2
|
+
import type { TemplateClusterReason } from '../archive/db-ops/templates/types.js';
|
|
3
|
+
import type Page from '../archive/page.js';
|
|
4
|
+
/**
|
|
5
|
+
* Progress of the clustering step itself. nitpicker's own copy of
|
|
6
|
+
* `@d-zero/page-cluster`'s `ProgressEvent` (which is structurally assignable
|
|
7
|
+
* to this type), kept independent of that package so `@nitpicker/cli` can
|
|
8
|
+
* format progress without depending on `@d-zero/page-cluster` — the same
|
|
9
|
+
* reason {@link TemplateClusterReason} mirrors `ClusterReason`.
|
|
10
|
+
*/
|
|
11
|
+
export type TemplateClusteringProgress = {
|
|
12
|
+
readonly phase: 'pass0-signals';
|
|
13
|
+
readonly pagesSeen: number;
|
|
14
|
+
} | {
|
|
15
|
+
readonly phase: 'pass1-block-complete';
|
|
16
|
+
readonly blockKey: string;
|
|
17
|
+
readonly blocksProcessed: number;
|
|
18
|
+
readonly totalBlocks: number;
|
|
19
|
+
} | {
|
|
20
|
+
readonly phase: 'pass1b-assign';
|
|
21
|
+
readonly pagesAssigned: number;
|
|
22
|
+
readonly pagesToAssign: number;
|
|
23
|
+
} | {
|
|
24
|
+
readonly phase: 'stage-b-start';
|
|
25
|
+
readonly unitCount: number;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Progress of the whole crawl-end classification
|
|
29
|
+
* ({@link import('./classify-archive-page-templates.js').classifyArchivePageTemplates}):
|
|
30
|
+
* loading every page handle out of the archive, gathering stylesheet
|
|
31
|
+
* references, the clustering phases, then writing the result.
|
|
32
|
+
*
|
|
33
|
+
* `loading-pages-start`, `collecting-stylesheets` and `writing-results` carry
|
|
34
|
+
* no count: each is a multi-second step with no natural progress unit (a
|
|
35
|
+
* single batched query, three chained SQL passes, one write transaction), so
|
|
36
|
+
* they only announce that the step began — otherwise the previous step's last
|
|
37
|
+
* message would stay on screen and look like a stall.
|
|
38
|
+
*/
|
|
39
|
+
export type TemplateClassificationProgress = {
|
|
40
|
+
readonly phase: 'loading-pages-start';
|
|
41
|
+
} | {
|
|
42
|
+
readonly phase: 'loading-pages';
|
|
43
|
+
readonly done: number;
|
|
44
|
+
readonly total: number;
|
|
45
|
+
} | {
|
|
46
|
+
readonly phase: 'collecting-stylesheets';
|
|
47
|
+
} | TemplateClusteringProgress | {
|
|
48
|
+
readonly phase: 'writing-results';
|
|
49
|
+
readonly templateCount: number;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Options for {@link import('./classify-page-templates.js').classifyPageTemplates}.
|
|
53
|
+
*/
|
|
54
|
+
export interface ClassifyPageTemplatesOptions {
|
|
55
|
+
/** The archive to read stylesheet references from. */
|
|
56
|
+
archive: Archive;
|
|
57
|
+
/**
|
|
58
|
+
* Every page of the archive. Classification is a corpus-wide batch
|
|
59
|
+
* computation: template keys are only comparable within one call, so the
|
|
60
|
+
* pages must never be passed in per-batch slices.
|
|
61
|
+
*/
|
|
62
|
+
pages: readonly Page[];
|
|
63
|
+
/**
|
|
64
|
+
* Progress callback forwarded to `@d-zero/page-cluster`'s
|
|
65
|
+
* `resolvePageClusterKeys`, so long-running classification on large
|
|
66
|
+
* archives isn't silently unresponsive. Independent of cluster-reason
|
|
67
|
+
* capture — `@d-zero/page-cluster` 0.5.3+ composes `onProgress` and
|
|
68
|
+
* `onClusterReason` without either one demoting the corpus off its
|
|
69
|
+
* progress-emitting path (see `classifyPageTemplates`'s own JSDoc).
|
|
70
|
+
*/
|
|
71
|
+
onProgress?: (event: TemplateClassificationProgress) => void;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Result of {@link import('./classify-page-templates.js').classifyPageTemplates}.
|
|
75
|
+
*/
|
|
76
|
+
export interface PageTemplateClassification {
|
|
77
|
+
/**
|
|
78
|
+
* Page URL (`page.url.href`) → template key. Only internal HTML pages
|
|
79
|
+
* with retrievable HTML have an entry.
|
|
80
|
+
*/
|
|
81
|
+
readonly templateKeysByUrl: ReadonlyMap<string, string>;
|
|
82
|
+
/**
|
|
83
|
+
* Template key → `@d-zero/page-cluster`'s cluster-selection evidence for
|
|
84
|
+
* that key. **Not guaranteed to cover every key in `templateKeysByUrl`**:
|
|
85
|
+
* `@d-zero/page-cluster` only emits a reason for a final cluster it still
|
|
86
|
+
* holds full grouping state for at the moment `onClusterReason` fires,
|
|
87
|
+
* which is a best-effort side channel rather than a per-page guarantee
|
|
88
|
+
* (unlike `templateKeysByUrl`, which is verified 1:1 against the yielded
|
|
89
|
+
* page set — see the hard length check in `classifyPageTemplates`).
|
|
90
|
+
*/
|
|
91
|
+
readonly clusterReasonsByTemplateKey: ReadonlyMap<string, TemplateClusterReason>;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Options for {@link import('./classify-archive-page-templates.js').classifyArchivePageTemplates}.
|
|
95
|
+
*/
|
|
96
|
+
export interface ClassifyArchivePageTemplatesOptions {
|
|
97
|
+
/** Receives loading and clustering progress; omit for a silent run. */
|
|
98
|
+
readonly onProgress?: (event: TemplateClassificationProgress) => void;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Result of {@link import('./classify-archive-page-templates.js').classifyArchivePageTemplates}.
|
|
102
|
+
*/
|
|
103
|
+
export interface ClassifyArchivePageTemplatesResult {
|
|
104
|
+
/** Number of pages that received a template key. */
|
|
105
|
+
readonly classifiedPageCount: number;
|
|
106
|
+
/** Number of distinct template keys among them. */
|
|
107
|
+
readonly templateCount: number;
|
|
108
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { TransferPhase } from './archive/transfer/types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Ordered whole-operation phase sequence `concatArchives`/`splitArchive`
|
|
4
|
+
* announce (via `sourceIndex === sources.length`) once every source has
|
|
5
|
+
* been transferred: `flattenRedirectChains` → `reclassifyResourceExternality`
|
|
6
|
+
* → `countExternalPagesInScope`. Identical for both commands — split's
|
|
7
|
+
* single source is already flat and its scope only shrinks, so the first
|
|
8
|
+
* two are cheap no-ops there, but the sequence itself does not branch.
|
|
9
|
+
*/
|
|
10
|
+
export declare const TRANSFER_POST_PHASES: readonly TransferPhase[];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ordered whole-operation phase sequence `concatArchives`/`splitArchive`
|
|
3
|
+
* announce (via `sourceIndex === sources.length`) once every source has
|
|
4
|
+
* been transferred: `flattenRedirectChains` → `reclassifyResourceExternality`
|
|
5
|
+
* → `countExternalPagesInScope`. Identical for both commands — split's
|
|
6
|
+
* single source is already flat and its scope only shrinks, so the first
|
|
7
|
+
* two are cheap no-ops there, but the sequence itself does not branch.
|
|
8
|
+
*/
|
|
9
|
+
export const TRANSFER_POST_PHASES = [
|
|
10
|
+
'flatteningRedirects',
|
|
11
|
+
'reclassifyingResources',
|
|
12
|
+
'countingExternalInScope',
|
|
13
|
+
];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nitpicker/crawler",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.23.0",
|
|
4
4
|
"description": "Web crawler engine with headless browser rendering and archive storage",
|
|
5
5
|
"author": "D-ZERO",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
"@d-zero/beholder": "5.0.0",
|
|
34
34
|
"@d-zero/dealer": "1.14.0",
|
|
35
35
|
"@d-zero/fs": "0.2.7",
|
|
36
|
+
"@d-zero/page-cluster": "0.8.0",
|
|
36
37
|
"@d-zero/shared": "0.23.0",
|
|
37
38
|
"ansi-colors": "4.1.3",
|
|
38
39
|
"debug": "4.4.3",
|
|
@@ -51,5 +52,5 @@
|
|
|
51
52
|
"@types/tar": "7.0.87",
|
|
52
53
|
"@types/unzipper": "0.10.11"
|
|
53
54
|
},
|
|
54
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "c62b266e166b1a1e98f0572c8579012abb25e3a7"
|
|
55
56
|
}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { eachSplitted } from '../../../utils/array/each-splitted.js';
|
|
2
|
-
import { compressPayload } from '../_shared/compress-payload.js';
|
|
3
|
-
/**
|
|
4
|
-
* Replaces the stored DOM-structure template classification (`--templates`)
|
|
5
|
-
* with a freshly generated set.
|
|
6
|
-
*
|
|
7
|
-
* Every classified page is a full-archive, all-or-nothing recomputation
|
|
8
|
-
* (see `@nitpicker/core`'s `classifyPageTemplates`), so this always deletes
|
|
9
|
-
* every existing row before inserting the new set — there is no per-page
|
|
10
|
-
* incremental update path, matching `replaceAnalysisViolations`'s
|
|
11
|
-
* whole-table replace shape. Unlike violations, a page whose URL can't be
|
|
12
|
-
* resolved back to a `content_items` row is silently skipped rather than
|
|
13
|
-
* treated as a hard failure: losing one page's template classification
|
|
14
|
-
* (e.g. a URL-normalization mismatch between the in-memory `Page.url.href`
|
|
15
|
-
* and the stored `url_refs.url`) should not discard the rest of a
|
|
16
|
-
* potentially multi-thousand-page classification run.
|
|
17
|
-
*
|
|
18
|
-
* `page_template_clusters` is always cleared alongside `page_templates`
|
|
19
|
-
* regardless of whether `clusterReasonsByTemplateKey` is passed — "no
|
|
20
|
-
* reason" must mean "not captured for this run", never "carry over the
|
|
21
|
-
* previous run's reason". Reason rows are inserted for every key in
|
|
22
|
-
* `clusterReasonsByTemplateKey` even if some have no surviving member page
|
|
23
|
-
* in `templateKeysByUrl` after URL-resolution skips above — harmless
|
|
24
|
-
* (nothing joins `page_template_clusters` back to `page_templates` by FK;
|
|
25
|
-
* see the table's own JSDoc), and simpler than cross-filtering the two maps.
|
|
26
|
-
* @param knex - Knex query builder connected to the archive DB.
|
|
27
|
-
* @param params - See {@link ReplacePageTemplatesParams}.
|
|
28
|
-
*/
|
|
29
|
-
export async function replacePageTemplates(knex, params) {
|
|
30
|
-
const { templateKeysByUrl, clusterReasonsByTemplateKey } = params;
|
|
31
|
-
// Compressing every reason is pure CPU work independent of the DB — done
|
|
32
|
-
// before opening the transaction below so it doesn't extend how long the
|
|
33
|
-
// SQLite write-lock is held for.
|
|
34
|
-
const reasonRows = clusterReasonsByTemplateKey && clusterReasonsByTemplateKey.size > 0
|
|
35
|
-
? [...clusterReasonsByTemplateKey].map(([templateKey, reason]) => {
|
|
36
|
-
const { body, codec, sizeRaw, sizeStored } = compressPayload(Buffer.from(JSON.stringify(reason), 'utf8'));
|
|
37
|
-
return {
|
|
38
|
-
template_key: templateKey,
|
|
39
|
-
member_count: reason.memberCount,
|
|
40
|
-
reason_json: body,
|
|
41
|
-
codec,
|
|
42
|
-
size_raw: sizeRaw,
|
|
43
|
-
size_stored: sizeStored,
|
|
44
|
-
};
|
|
45
|
-
})
|
|
46
|
-
: [];
|
|
47
|
-
await knex.transaction(async (trx) => {
|
|
48
|
-
await trx('page_templates').delete();
|
|
49
|
-
await trx('page_template_clusters').delete();
|
|
50
|
-
if (reasonRows.length > 0) {
|
|
51
|
-
await eachSplitted(reasonRows, 100, async (chunk) => {
|
|
52
|
-
await trx('page_template_clusters').insert(chunk);
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
if (templateKeysByUrl.size === 0) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
const urls = [...templateKeysByUrl.keys()];
|
|
59
|
-
const pageIdByUrl = new Map();
|
|
60
|
-
await eachSplitted(urls, 500, async (chunk) => {
|
|
61
|
-
const pageRows = await trx('content_items')
|
|
62
|
-
.join('url_refs', 'url_refs.id', 'content_items.url_id')
|
|
63
|
-
.select('content_items.id as id', 'url_refs.url as url')
|
|
64
|
-
.whereIn('url_refs.url', chunk);
|
|
65
|
-
for (const row of pageRows) {
|
|
66
|
-
pageIdByUrl.set(row.url, row.id);
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
const rows = [];
|
|
70
|
-
for (const [url, templateKey] of templateKeysByUrl) {
|
|
71
|
-
const pageId = pageIdByUrl.get(url);
|
|
72
|
-
if (pageId == null) {
|
|
73
|
-
continue;
|
|
74
|
-
}
|
|
75
|
-
rows.push({ page_id: pageId, template_key: templateKey });
|
|
76
|
-
}
|
|
77
|
-
if (rows.length === 0) {
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
await eachSplitted(rows, 500, async (chunk) => {
|
|
81
|
-
await trx('page_templates').insert(chunk);
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
}
|
|
File without changes
|