Mercurial > hgrepos > hgweb.cgi > s4
changeset 278:2f1607d8b56b
New access log schema started
author | HIROSE Yuuji <yuuji@gentei.org> |
---|---|
date | Tue, 02 Aug 2016 13:25:47 +0859 |
parents | cfbedd0686dd |
children | 7d7b81cfd3a0 |
files | s4-funcs.sh s4-init.sh |
diffstat | 2 files changed, 15 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/s4-funcs.sh Tue Aug 02 10:08:34 2016 +0859 +++ b/s4-funcs.sh Tue Aug 02 13:25:47 2016 +0859 @@ -447,7 +447,8 @@ if [ -n "$n" ]; then now=`date +"%F %T"` #query "replace into acclog values('$user', '$1', '$n', '$now');" - query "replace into acclog values('$user', '$1', $n, '$now');" + #query "replace into acclog values('$user', '$1', $n, '$now');" + query "replace into tblaccesses values('$user', '$1', $n, '$now');" fi ) gecos() (
--- a/s4-init.sh Tue Aug 02 10:08:34 2016 +0859 +++ b/s4-init.sh Tue Aug 02 13:25:47 2016 +0859 @@ -71,9 +71,20 @@ create table par '(sessid text, var text, type text, val text, primary key(sessid, var, val) foreign key(sessid) references session(id) on update cascade on delete cascade);' create table session '(id text primary key, expire text);' create table cookie '(sessid text, var text, type text, val text, primary key(sessid, var) foreign key(sessid) references session(id) on update cascade on delete cascade);' -create table acclog "(user, tbl, tblrowid, time, \ - primary key(user, tbl, tblrowid), \ +tblacc=`query "select name from sqlite_master where name='tblaccesses';"` +acc=`query "select name from sqlite_master where name='acclog';"` +echo tblacc="[$tblacc]" acc="[$acc]" +create table tblaccesses "(user, tbl, tblrowid, time, \ + unique(user, tbl, tblrowid, time), \ foreign key(user) references user(name))" +if [ -z "$tblacc" -a -n "$acc" ]; then + echo Regenerating... + query "INSERT INTO tblaccesses SELECT * FROM acclog; +DROP TABLE acclog;" +fi +create view acclog "AS +SELECT user, tbl, tblrowid, max(time) time FROM tblaccesses +GROUP by user, tbl, tblrowid;" create view gecoses "AS SELECT rowid,