Commit 83591a31 authored by Ted Trask's avatar Ted Trask

Added pagination for history and usage, more precision for history timestamp.

parent f2c79a9f
......@@ -46,7 +46,7 @@ These tables contain the combined squid access log and dansguardian log for ever
This table contains the database history, including such information as which log files were loaded and how many entries they contained. The definition of the table is as follows:
<pre>
(
logdatetime timestamp(0) without time zone NOT NULL,
logdatetime timestamp(3) without time zone NOT NULL,
msgtext text
)
</pre>
......
......@@ -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
......
<% local data, viewlibrary, page_info, session = ... %>
<% require("viewfunctions") %>
<% local subdata, pagedata = paginate(data.value, page_info.clientdata, 100) %>
<H1><%= html.html_escape(data.label) %></H1>
<% displaypagination(pagedata, page_info) %>
<TABLE>
<TR style="background:#eee;font-weight:bold;">
<TD style="padding-right:20px;white-space:nowrap;" class="header">Date</TD>
<TD style="white-space:nowrap;" WIDTH="90%" class="header">Message</TD>
</TR>
<% for i,log in ipairs(data.value) do %>
<% for i,log in ipairs(subdata) do %>
<TR>
<TD><%= html.html_escape(log.logdatetime) %></TD>
<TD><%= html.html_escape(string.gsub(log.logdatetime, "%..*", "")) %></TD>
<TD><%= html.html_escape(log.msgtext) %></TD>
</TR>
<% end %>
......
<% local data, viewlibrary, page_info, session = ... %>
<% require("viewfunctions") %>
<% local subdata, pagedata = paginate(data.value, page_info.clientdata, 100) %>
<H1><%= html.html_escape(data.label) %></H1>
<% displaypagination(pagedata, page_info) %>
<TABLE>
<TR style="background:#eee;font-weight:bold;">
<TD style="padding-right:20px;white-space:nowrap;" class="header">Date</TD>
......@@ -8,7 +13,7 @@
<TD style="white-space:nowrap;" WIDTH="90%" class="header">Blocks</TD>
</TR>
<% for i,stat in ipairs(data.value) do %>
<% for i,stat in ipairs(subdata) do %>
<TR>
<TD><%= html.html_escape(stat.date) %></TD>
<TD><%= html.html_escape(stat.sourcename) %></TD>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment