Skip to content

Commit 32650e0

Browse files
committed
Version 2 Commit
1 parent cbeecb3 commit 32650e0

File tree

4 files changed

+38
-32
lines changed

4 files changed

+38
-32
lines changed

canvashelper.js

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -110,34 +110,35 @@ class CanvasHelper {
110110
.filter(assignment => typeof assignment.name !== 'undefined')
111111
.map((assignment) =>
112112
({
113-
"Assignment Name": {
114-
type: "title",
115-
title: [{
116-
type: "text",
117-
text: { content: assignment.name }
118-
}]
119-
},
120-
"Due Date": {
121-
type: "date",
122-
date: { start: assignment.due_at || '2020-09-10'}
123-
},
124-
"Course": {
125-
select: {
126-
name: courseName
127-
}
128-
},
129-
"URL": {
130-
type: "url",
131-
url: assignment.html_url
132-
},
133-
"ID": {
134-
type: "number",
135-
number: assignment.id,
136-
},
137-
}))
113+
"Assignment Name": {
114+
type: "title",
115+
title: [{
116+
type: "text",
117+
text: { content: assignment.name }
118+
}]
119+
},
120+
"Due Date": {
121+
type: "date",
122+
date: { start: assignment.due_at || '2020-09-10'}
123+
},
124+
"Course": {
125+
select: {
126+
name: courseName
127+
}
128+
},
129+
"URL": {
130+
type: "url",
131+
url: assignment.html_url
132+
},
133+
"ID": {
134+
type: "number",
135+
number: assignment.id,
136+
},
137+
}
138+
))
138139

139140
// list of assignments for the course
140-
return await assignment_list
141+
return await assignment_list
141142
}
142143
}
143144

main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ const NotionClient = new Client({ auth: NotionHelp.api})
1717
* If so, update the database, else create a new database.
1818
*/
1919
async function checkDatabase() {
20+
const courses = await CanvasHelp.getCourses()
2021
try {
21-
const courses = await CanvasHelp.getCourses()
2222
const response = await NotionClient.databases.query({
2323
database_id: NotionHelp.database
2424
})

notionhelper.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class NotionHelper {
6969

7070
return notion_pages
7171
} catch(error) {
72-
console.log(`ERROR: () did not run: ${error}`)
72+
console.log(`ERROR: getNotionPages() did not run: ${error}`)
7373
}
7474
}
7575

@@ -174,7 +174,6 @@ class NotionHelper {
174174
},
175175
})
176176
console.log(`SUCCESS: Database has been updated!`)
177-
// only add assignments for new courses -> less api calls
178177
} catch (error) {
179178
console.log(`ERROR: Database could not be update! ${error}`)
180179
}
@@ -191,12 +190,11 @@ class NotionHelper {
191190
type: "database_id",
192191
database_id: this.database
193192
},
194-
properties: page_properties,
193+
properties: await page_properties,
195194
})
196195
console.log(`SUCCESS: new page ${page_properties.ID.number} has been created!`)
197196
} catch (error) {
198-
console.log(page_properties)
199-
console.log(`ERROR: createPage failed!\n${error}`)
197+
console.log(`ERROR: createNotionPage failed!\n${error}`)
200198
}
201199
}
202200

util.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,11 @@ function setEnvValue(key, value) {
2626
fs.writeFileSync("./.env", ENV_VARS.join(os.EOL));
2727
}
2828

29+
/**
30+
* Potential function for future use.
31+
*/
32+
const htmlToNotion = () => {
33+
34+
}
35+
2936
module.exports = { setEnvValue }

0 commit comments

Comments
 (0)