Skip to content

Commit

Permalink
Function to archive uploaded csv files for debugging.
Browse files Browse the repository at this point in the history
  • Loading branch information
nugget committed Feb 24, 2012
1 parent ab8c983 commit e2c229d
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
14 changes: 14 additions & 0 deletions db/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ INSERT INTO config (item,value) VALUES ('rkapi_client_secret','0123456789abcdef'
INSERT INTO config (item,value) VALUES ('rkapi_auth_url','https://runkeeper.com/apps/authorize');
INSERT INTO config (item,value) VALUES ('rkapi_token_url','https://runkeeper.com/apps/token');
INSERT INTO config (item,value) VALUES ('allow_registration','true');
INSERT INTO config (item,value) VALUES ('archive_logs','false');

CREATE TABLE users (
id bigint NOT NULL,
Expand Down Expand Up @@ -82,4 +83,17 @@ CREATE TABLE activities (
);
GRANT ALL ON activities_id_seq TO c2rkwww;
GRANT SELECT,INSERT,UPDATE ON activities TO c2rkwww;
CREATE TRIGGER onupdate BEFORE UPDATE ON activities FOR EACH ROW EXECUTE PROCEDURE onupdate_changed();

CREATE TABLE logs (
id serial NOT NULL,
added timestamp(0) without time zone NOT NULL DEFAULT (current_timestamp at time zone 'utc'),
changed timestamp(0) without time zone NOT NULL DEFAULT (current_timestamp at time zone 'utc'),
deleted timestamp(0) without time zone,
user_id integer NOT NULL REFERENCES users(id),
csvdata text NOT NULL,
PRIMARY KEY(id)
);
GRANT ALL ON logs_id_seq TO c2rkwww;
GRANT SELECT,INSERT ON logs TO c2rkwww;
CREATE TRIGGER logs BEFORE UPDATE ON activities FOR EACH ROW EXECUTE PROCEDURE onupdate_changed();
11 changes: 11 additions & 0 deletions packages/ergkeeper/common.tcl
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
proc opt_bool {item} {
set retval 0

if {[info exists ::config($item)]} {
set retval [string is true $::config($item)]
}

return $retval
}


package provide ergkeeper 1.0
7 changes: 6 additions & 1 deletion webroot/upload.rvt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

puts "<center>"

form myform -defaults response -method post -name chooser -action post -enctype "multipart/form-data"
form myform -defaults response -method post -name chooser -enctype "multipart/form-data"
myform start

puts "<table>"
Expand Down Expand Up @@ -51,6 +51,11 @@
#puts "<h1>$filename</h1>"
#puts "<pre>$log</pre>"

if {[opt_bool archive_logs]} {
set sql "INSERT INTO logs (user_id,csvdata) SELECT $::user(id), [pg_quote $log]"
sql_exec $::db $sql
}

runkeeper_import_new_activities $::user(id) $log

page_foot
Expand Down

0 comments on commit e2c229d

Please sign in to comment.