-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
62 lines (59 loc) · 2.4 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// Initializing a client
const notion = require("./setup.js");
const { traverseRows } = require("./lib.js");
async function updateURLCopyLink(row, i, response) {
const row = response.results[j];
const properties = row.properties;
const href = properties["Link"]?.rich_text?.[0]?.href ?? "";
const url = properties["URL"]?.url ?? "";
const finalUrl = url || href;
if (!finalUrl || url) return;
// console.log(
// row.id,
// row.properties.Name.title[0].plain_text,
// Object.keys(row)
// );
notion.pages.update({
page_id: row.id,
properties: {
URL: { url: finalUrl },
},
});
}
const DATA = [
"https://www.geeksforgeeks.org/problems/construct-tree-from-inorder-and-levelorder/1",
"https://www.geeksforgeeks.org/problems/detect-cycle-in-a-directed-graph/1",
"https://www.geeksforgeeks.org/problems/minimum-spanning-tree/1",
"https://www.geeksforgeeks.org/problems/union-find/1",
"https://www.geeksforgeeks.org/problems/implementing-dijkstra-set-1-adjacency-matrix/1",
"https://www.geeksforgeeks.org/problems/strongly-connected-components-kosarajus-algo/1",
"https://leetcode.com/problems/remove-linked-list-elements/",
"https://leetcode.com/problems/binary-tree-level-order-traversal/",
"https://leetcode.com/problems/construct-binary-tree-from-inorder-and-postorder-traversal/",
"https://leetcode.com/problems/construct-binary-tree-from-preorder-and-postorder-traversal/ ",
"https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/",
"https://leetcode.com/problems/balance-a-binary-search-tree",
"https://leetcode.com/problems/search-in-a-binary-search-tree/",
"https://leetcode.com/problems/count-complete-tree-nodes/",
"https://leetcode.com/problems/check-completeness-of-a-binary-tree/",
"https://leetcode.com/problems/find-the-length-of-the-longest-common-prefix/",
"https://leetcode.com/problems/implement-trie-prefix-tree/",
"https://leetcode.com/problems/design-add-and-search-words-data-structure/",
"https://leetcode.com/problems/is-graph-bipartite",
];
async function insertData(data = []) {
for (let i = 0; i < data.length; i++) {
const datum = data[i];
await notion.pages.create({
parent: {
type: "database_id",
database_id: process.env.DATABASE_ID,
},
properties: {
URL: { url: datum },
},
});
}
}
// traverseRows(updateURLCopyLink);
// insertData(DATA);