-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackend.rb
More file actions
30 lines (26 loc) · 842 Bytes
/
backend.rb
File metadata and controls
30 lines (26 loc) · 842 Bytes
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
require 'sqlite3'
require 'socket'
server = TCPServer.open(80)
loop{
Thread.start(server.accept) do |client|
end
}
db = SQLite3::Database.new("data.db")
db.execute("UPDATE data SET hits = 0")
#=begin
db.execute("UPDATE data SET hits = hits + 1 WHERE time = ?", "9:00")
db.execute("UPDATE data SET hits = hits + 1 WHERE month = ?", "11")
db.execute("UPDATE data SET hits = hits + 1 WHERE day = ?", "09")
db.execute("UPDATE data SET hits = hits + 1 WHERE radiation = ?", 120)
db.execute("UPDATE data SET hits = hits + 1 WHERE humidity = ?", 0.6)
db.execute("UPDATE data SET hits = hits + 1 WHERE temp = ?", 2)
db.execute("UPDATE data SET hits = hits + 1 WHERE wind = ?", 6)
#=end
i = 0
temp = 0
db.execute("SELECT id FROM data WHERE hits >= 5") do |row|
i = i + 1
#puts(row)
temp = temp + row[0]
end
puts(temp/i)