-
Notifications
You must be signed in to change notification settings - Fork 4
/
app.rb
72 lines (62 loc) · 1.84 KB
/
app.rb
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
[
'sinatra',
'open-uri',
'openssl',
'json'
].each{|g|
require g
}
[
'models/classes',
'helpers/methods'
].each{|rb|
require_relative rb+'.rb'
}
get '/' do
erb :index
end
get '/jobs' do
returnArray = []
newGSheet = GSheet.new
newGSheet.sheetId = ENV['JOBS_GSHEET_ID']
jobListingDataArray = newGSheet.showData
jobListingDataArray.each_with_index{|jobData,idx|
g = 'gsx$'
t = '$t'
deadlineString = jobData[g+'applicationdeadline'][t]
if(deadlineString!='')
deadlineDateTime = DateTime.strptime(deadlineString,'%m/%d/%Y %H:%M:%S')
now = DateTime.now
if(deadlineDateTime>now===false)
next
end
end
if(jobData[g+'closed'][t].to_i!=0 || jobData[g+'approved'][t].to_i!=1)
next
end
returnHash = {
:jobTitle => jobData[g+'jobtitle'][t],
:moreInfoURL => addHTTP(jobData[g+'wherecanifindoutmoreaboutthisjob'][t]),
:company => jobData[g+'company'][t],
:jobDescription => jobData[g+'jobdescription'][t],
:skills => jobData[g+'skillsrequired'][t],
:jobLocation => jobData[g+'location'][t],
:partTime => jobData[g+'isthisfulltimeorparttimework'][t],
:companyURL => addHTTP(jobData[g+'companywebsiteurl'][t]),
:apply => jobData[g+'howtoapply'][t],
:pay => jobData[g+'whatsthepay'][t],
:payPeriod => jobData[g+'isthatthepayrateperhourweekmonthoryear'][t],
:deadline => jobData[g+'applicationdeadline'][t],
:internship => jobData[g+'isthispositionaninternship'][t],
:closed => jobData[g+'closed'][t],
:approved => jobData[g+'approved'][t],
:submitted => jobData[g+'timestamp'][t].match(/.*(?=\s)/).to_s
}
returnArray << returnHash
}
returnJSON = returnArray.reverse.to_json # Reverse array so jobs are ordered by submitted date, most recent first,
return returnJSON
end
get '/submit' do
redirect 'https://docs.google.com/forms/d/127JNB-_U7PvMSXs5R0PhiVffFNdqhvlHixNgmbsMWmY/viewform'
end