-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathpost.rvt
48 lines (38 loc) · 1.22 KB
/
post.rvt
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
<?
package require ergkeeper
::ergkeeper::page_init
::ergkeeper::page_response
::ergkeeper::page_head
::ergkeeper::require_login
unset -nocomplain idlist
foreach f [array names response sel_*] {
if {[regexp {sel_(\d+)} $f _ id]} {
lappend idlist $id
}
}
unset -nocomplain whereclauses
lappend whereclauses "deleted IS NULL"
lappend whereclauses "user_id = $::user(id)"
if {![info exists response(resubmit)]} {
lappend whereclauses "posted IS NULL"
}
puts "<ol>"
if {[info exists idlist]} {
pg_select $::db "SELECT * FROM activities WHERE [join $whereclauses " AND "] AND id IN ([join $idlist ","])" buf {
set id $buf(id)
if {[info exists response(notes_$id)] && $response(notes_$id) != ""} {
sql_exec $::db "UPDATE activities SET notes = [pg_quote $response(notes_$id)] WHERE id = $id"
}
lassign [runkeeper_post_activity $id] status details_data
unset -nocomplain details
array set details $details_data
puts "<li>Posting activity $id to RunKeeper ($details(status))</li>"
if {[string is true $status]} {
sql_exec $::db "UPDATE activities SET posted = current_timestamp at time zone 'utc' WHERE id = $id"
}
}
}
puts "</ol>"
::ergkeeper::page_foot
::ergkeeper::page_term
?>