-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrecord.js
More file actions
79 lines (74 loc) · 2.27 KB
/
Copy pathrecord.js
File metadata and controls
79 lines (74 loc) · 2.27 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*
* record.js
*
* This is the file that should be run from the command line to test changes in recording
* in Airtable. Designed to assist in the debugging process by isolatiing the singular
* step of creating new Airtable records. Uses Camille's slack ID to do so. The tester
* SlackID can be changed as long as it exists in the table.
*
* by Camille Cooper
* for HackCville, Inc.
*
* May 2020
*
*/
const AIRTABLE_API_KEY = process.env.AIRTABLE_API_KEY;
const AIRTABLE_BASE_ID = process.env.AIRTABLE_BASE_ID_LIVE;
const TABLE_NAME = "Launch 2020 Student Feedback";
var Airtable = require("airtable");
var base = new Airtable({ apiKey: AIRTABLE_API_KEY }).base(AIRTABLE_BASE_ID);
//static data that replicates how slack would pass the info. this is what gets recorded
var payload = {
user: { id: "UETEHA6NN" },
submission: {
pace: 3,
combo: 3,
lecture: 3,
understanding: 3,
enjoyment: 3,
},
};
var student_name = "";
var student_link = [];
base("Launch Students")
.select({
maxRecords: 1,
view: "Camille View",
filterByFormula: "{Slack ID}= '" + payload.user.id + "'",
})
.eachPage((records, fetchNextPage) => {
records.forEach((record) => {
console.log("Retrieved", record.get("Student Name"));
student_name = record.get("Student Name");
student_link.push(record.id);
});
fetchNextPage();
})
.then(() => {
//record the dialog response in Airtable
base(TABLE_NAME).create(
[
{
fields: {
Name: student_name,
SlackID: payload.user.id,
"Pace Rating": Number(payload.submission.pace),
"Lecture/Reading Rating": Number(payload.submission.combo),
"Lecture Length Rating": Number(payload.submission.lecture),
"Understanding Rating": Number(payload.submission.understanding),
// "Group Rating": Number(payload.submission.group),
"Enjoyment Rating": Number(payload.submission.enjoyment),
// Strength: payload.submission.strength,
// Weakness: payload.submission.weakness,
// "Student Link": student_link,
},
},
],
function (err, records) {
if (err) {
console.error(err);
return;
}
}
);
});