-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfeedbag.rb
61 lines (53 loc) · 1.39 KB
/
feedbag.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
require 'sinatra'
require 'help_spot'
require 'data_mapper'
DataMapper::setup(:default, "sqlite3://#{Dir.pwd}/feedbag.db")
class Rating
include DataMapper::Resource
property :id, Serial
property :rating, Enum[:good, :okay, :bad]
property :agent, String
property :request, String
property :request_password, String
property :reply, String
property :feedback, Text
property :created_at, DateTime
end
DataMapper.finalize.auto_upgrade!
# helpers do
# def get_reply(request, timestamp)
# help_spot = HelpSpot.new 'http://support.monkdevelopment.com/api/', '[email protected]', 'eYTjj7Z4Ec'
# response = help_spot.request request
# request_history = response.request_history
# stuff = ''
# request_history.each do |x|
# if (x.dtGMTChange.delete(' ') == timestamp.delete(' ')) && !x.tLog
# stuff = x.xRequestHistory
# end
# end
# return stuff
# end
# end
get '/' do
erb :home
end
get '/rate/:accesskey/:rating' do
@accesskey = params[:accesskey]
r = Rating.new
r.rating = params[:rating]
r.request = @accesskey[0,5]
r.request_password = @accesskey[5,5]
r.created_at = Time.now
r.save
redirect "/rating/#{@accesskey}/#{r.id}"
end
get '/rating/:accesskey/:id' do
@rating = Rating.get params[:id]
erb :feedback
end
put '/rating/:id' do
r = Rating.get params[:id]
r.feedback = params[:feedback]
r.save
redirect '/'
end