Skip to content

Commit cdad455

Browse files
author
Chad Dougherty
authored
Merge branch 'main' into jobs
2 parents 562cdff + 24c1b37 commit cdad455

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

scripts/jobs-form-exporter.gs

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// This crude script sends an email with information about a jobs board
2+
// form submission, including a prepared YAML representation suitable
3+
// for pasting into a GitHub PR.
4+
//
5+
// It should be installed into the Google Sheet backing the US-RSE jobs
6+
// board submission form through "Extensions->Apps Script->Code.gs",
7+
// and configured to run "onSubmit".
8+
//
9+
// NOTE: this script assumes that the data from the cells is non-null
10+
// because the Google Form marks all of the fields as required
11+
// Also, be sure to update the "mailto" value below with the actual
12+
// intended list of receipients when putting it into Google.
13+
//
14+
// sample entry:
15+
// - expires: 2022-11-30
16+
// location: Globus - University of Chicago, Chicago, IL or remote/flexible
17+
// name: Software Engineer
18+
// posted: 2022-09-12
19+
// url: https://uchicago.wd5.myworkdayjobs.com/External/job/Chicago-IL/Software-Engineer_JR17859
20+
//
21+
//
22+
function onFormSubmit(e) {
23+
var ss = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
24+
var rowID = ss.getLastRow();
25+
26+
// mail message parameters
27+
const mailto = '[email protected]'; // add new recipients here, separated by comma
28+
const mailsubject = 'US-RSE Jobs Form notification';
29+
var mailbody = 'Raw data for US-RSE job form submission: ' + rowID + '\n';
30+
var data = [];
31+
32+
var headers = ss.getRange(1, 1, 1, ss.getLastColumn()).getValues()[0];
33+
for (var header in headers) {
34+
mailbody += headers[header] + ': ' + e.namedValues[headers[header]].toString() + '\n';
35+
data.push(e.namedValues[headers[header]]);
36+
}
37+
38+
// naive mapping of cells to elements. sorry, this is gross
39+
const location = data[4] + ', ' + data[5];
40+
const name = data[3];
41+
const url = data[6];
42+
// convert MM/DD/YYYY to YYYY-MM-DD. surely there's got to be a simpler way to do these...
43+
var exptmp = new Date(data[7]);
44+
var expires = exptmp.toISOString().split('T')[0];
45+
var posttmp = new Date();
46+
var posted = posttmp.toISOString().split('T')[0];
47+
48+
mailbody += '\n\n\nPrepared YAML for US-RSE job form submission: ' + rowID + '\n';
49+
mailbody += 'Prepend this to the appropriate jobs file, _data/jobs.yml or _data/related-jobs.yml.\n'
50+
mailbody += 'NOTE: this is a rough conversion. Be sure to sanity check before using it verbatim.\n\n';
51+
mailbody += '\
52+
- expires: ' + expires + '\n\
53+
location: ' + location + '\n\
54+
name: ' + name + '\n\
55+
posted: ' + posted + '\n\
56+
url: ' + url + '\n'
57+
58+
// Send the email
59+
GmailApp.sendEmail(mailto, mailsubject, mailbody);
60+
}

0 commit comments

Comments
 (0)