From 83591a31c7d27155e47b35c2e62d2662b759f462 Mon Sep 17 00:00:00 2001 From: Ted Trask Date: Mon, 21 Sep 2009 11:03:41 +0000 Subject: Added pagination for history and usage, more precision for history timestamp. --- weblog-model.lua | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'weblog-model.lua') diff --git a/weblog-model.lua b/weblog-model.lua index 14f394f..c4d5080 100644 --- a/weblog-model.lua +++ b/weblog-model.lua @@ -19,7 +19,7 @@ local configcontent = fs.read_file(configfile) or "" local config = format.parse_ini_file(configcontent, "") or {} local database_creation_script = { - "CREATE TABLE dbhistlog (logdatetime timestamp(0) without time zone NOT NULL, msgtext text)", + "CREATE TABLE dbhistlog (logdatetime timestamp(3) without time zone NOT NULL, msgtext text)", "CREATE TABLE pubblocklog(sourcename character varying(40), clientip inet NOT NULL, clientuserid character varying(64) NOT NULL, logdatetime timestamp(3) without time zone NOT NULL, uri text NOT NULL, bytes integer NOT NULL, reason text, score integer, shortreason text)", "CREATE TABLE blocklog(sourcename character varying(40), clientip inet NOT NULL, clientuserid character varying(64) NOT NULL, logdatetime timestamp(0) without time zone NOT NULL, uri text NOT NULL, bytes integer NOT NULL, reason text, score integer, shortreason text)", "CREATE TABLE pubweblog(sourcename character varying(40), clientip inet NOT NULL, clientuserid character varying(64) NOT NULL, logdatetime timestamp(3) without time zone NOT NULL, uri text NOT NULL, bytes integer NOT NULL, reason text, score integer, shortreason text)", @@ -160,8 +160,7 @@ local databasedisconnect = function() end local logme = function(message) - local sql = string.format("INSERT INTO dbhistlog VALUES ('%s', '%s')", - os.date("%Y-%m-%d %H:%M:%S"), escape(message)) + local sql = string.format("INSERT INTO dbhistlog VALUES ('now', '%s')", escape(message)) local res = assert (con:execute(sql)) end @@ -479,7 +478,7 @@ local listusagestats = function() local entries = {} -- retrieve a cursor local sql = "SELECT sourcename, date, sum(numrequest) AS numrequest, sum(numblock) AS numblock " .. - "FROM usagestat GROUP BY sourcename, date ORDER BY sourcename, date" + "FROM usagestat GROUP BY sourcename, date ORDER BY date, sourcename" cur = assert (con:execute(sql)) row = cur:fetch ({}, "a") while row do -- cgit v1.2.3