add architecture to submissions
This commit is contained in:
parent
fce3a5ef2f
commit
7266ba9698
2
mkdb.tcl
2
mkdb.tcl
|
@ -7,6 +7,7 @@ sqlite3 db register.db
|
|||
# clients will submit at 9 AM their time.
|
||||
db eval {CREATE TABLE hits
|
||||
( ip_address_hash TEXT NOT NULL
|
||||
, arch TEXT NOT NULL
|
||||
, date TEXT NOT NULL
|
||||
)}
|
||||
|
||||
|
@ -16,6 +17,7 @@ db eval {CREATE UNIQUE INDEX hits_unique_daily ON hits(ip_address_hash, date)}
|
|||
# table, but databases have indexes for a reason.
|
||||
db eval {CREATE TABLE package_installs
|
||||
( package_name TEXT NOT NULL
|
||||
, arch TEXT NOT NULL
|
||||
, date TEXT NOT NULL
|
||||
)}
|
||||
|
||||
|
|
19
site.tcl
19
site.tcl
|
@ -22,10 +22,16 @@ proc wapp-default {} {
|
|||
}
|
||||
|
||||
proc wapp-page-submit {} {
|
||||
wapp-allow-xorigin-params
|
||||
|
||||
set systemTime [clock seconds]
|
||||
set iphash [md5::md5 [wapp-param REMOTE_ADDR]]
|
||||
|
||||
set method [wapp-param REQUEST_METHOD]
|
||||
set arch [wapp-param arch]
|
||||
set body [wapp-param CONTENT "<INVALID>"]
|
||||
|
||||
wapp-set-param TODAY $systemTime
|
||||
wapp-set-param IPHASH $iphash
|
||||
|
||||
if {[string match {POST} $method] == 0} {
|
||||
# bad method
|
||||
|
@ -38,11 +44,6 @@ proc wapp-page-submit {} {
|
|||
return
|
||||
}
|
||||
|
||||
wapp-set-param TODAY $systemTime
|
||||
wapp-set-param IPHASH $iphash
|
||||
|
||||
set body [wapp-param CONTENT "<INVALID>"]
|
||||
|
||||
if {[string match {<INVALID>} $body] == 1} {
|
||||
# bad request
|
||||
wapp-reply-code 400
|
||||
|
@ -55,11 +56,13 @@ proc wapp-page-submit {} {
|
|||
}
|
||||
|
||||
db eval {BEGIN}
|
||||
db eval {INSERT INTO hits(ip_address_hash, date) VALUES ($iphash, date($systemTime, 'unixepoch'))}
|
||||
db eval {INSERT INTO hits(ip_address_hash, arch, date) VALUES ($iphash, $arch, date($systemTime, 'unixepoch'))}
|
||||
|
||||
set pkgs [split $body "\n"]
|
||||
foreach pkg $pkgs {
|
||||
db eval {INSERT INTO package_installs(package_name, date) VALUES ($pkg, date($systemTime, 'unixepoch'))}
|
||||
if {[string length $pkg] != 0} {
|
||||
db eval {INSERT INTO package_installs(package_name, arch, date) VALUES ($pkg, $arch, date($systemTime, 'unixepoch'))}
|
||||
}
|
||||
}
|
||||
|
||||
db eval {COMMIT}
|
||||
|
|
Loading…
Reference in New Issue