summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimo Teras <timo.teras@iki.fi>2009-09-19 10:47:59 +0300
committerTimo Teras <timo.teras@iki.fi>2009-09-19 10:47:59 +0300
commitf2c79a9fb3c0a96b16c8f723848cee90ab173c57 (patch)
tree4425745cc8ceb18de683c26dcb0af90090234bbb
parenta4762be030f774bdd449609c127d97fbd5466210 (diff)
downloadacf-weblog-f2c79a9fb3c0a96b16c8f723848cee90ab173c57.tar.bz2
acf-weblog-f2c79a9fb3c0a96b16c8f723848cee90ab173c57.tar.xz
Sort history by date.
Fix also some white space stuff (cleaned up automatically by my editor).
-rw-r--r--weblog-model.lua34
1 files changed, 17 insertions, 17 deletions
diff --git a/weblog-model.lua b/weblog-model.lua
index 867e677..14f394f 100644
--- a/weblog-model.lua
+++ b/weblog-model.lua
@@ -93,13 +93,13 @@ local createdatabase = function(password)
f = io.popen(cmd)
table.insert(result, f:read("*a"))
f:close()
-
+
-- Create the database
cmd = path..'psql -U postgres -c "CREATE DATABASE '..DatabaseName..' WITH OWNER '..DatabaseOwner..'" 2>&1'
f = io.popen(cmd)
table.insert(result, f:read("*a"))
f:close()
-
+
return table.concat(result, "\n")
end
@@ -119,7 +119,7 @@ local deletedatabase = function()
f = io.popen(cmd)
table.insert(result, f:read("*a"))
f:close()
-
+
return table.concat(result, "\n")
end
@@ -168,7 +168,7 @@ end
local listhistorylogentries = function()
local entries = {}
-- retrieve a cursor
- cur = assert (con:execute"SELECT logdatetime, msgtext from dbhistlog")
+ cur = assert (con:execute"SELECT logdatetime, msgtext from dbhistlog ORDER BY logdatetime")
row = cur:fetch ({}, "a")
while row do
entries[#entries+1] = {logdatetime = row.logdatetime, msgtext = row.msgtext}
@@ -289,7 +289,7 @@ local importpubweblog = function()
"weblog.uri like (blocklog.uri || '%')"
res = assert (con:execute(sql))
logme("importpubweblog merged " .. res .. " blocks with matching timestamps.")
-
+
sql = "insert into weblog select * from blocklog where " ..
" NOT EXISTS (select * from weblog where " ..
"blocklog.logdatetime >= date_trunc('second', weblog.logdatetime) and " ..
@@ -312,12 +312,12 @@ local importpubweblog = function()
res = assert (con:execute(sql))
logme("importpubweblog imported " .. res .. " new blocks into block table.")
- -- grab the bypass info
+ -- grab the bypass info
sql = "insert into pubblocklog select * from weblog where uri like '%?GBYPASS%'"
res = assert (con:execute(sql))
logme("importpubweblog imported " .. res .. " dg bybass events into block table.")
- -- Truncate the staging tables
+ -- Truncate the staging tables
assert (con:execute("truncate weblog"))
assert (con:execute("truncate blocklog"))
logme("truncated staging tables")
@@ -366,7 +366,7 @@ local groompublogs = function()
local temp = config.auditstart
if not temp or temp == "" then temp = os.date("%Y-%m-%d %H:%M:%S") end
logme("Purge date since last audit is " .. tostring(watchdays+historydays) .. " days before " .. temp .. ".")
-
+
sql = "delete from pubweblog where logdatetime < (timestamp '"..temp.."' - INTERVAL '"..tostring(watchdays+historydays).." days')"
res = assert (con:execute(sql))
logme("removed " .. res .. " old pubweblog records that are older than history+watchdays")
@@ -377,7 +377,7 @@ local groompublogs = function()
-- purge good people after historydays
logme("The delete date for non-watchlist users is " .. tostring(historydays) .. " days before " .. temp .. ".")
-
+
sql = "delete from pubweblog where logdatetime < (timestamp '".. temp.."' - INTERVAL '"..tostring(historydays).." days') and clientuserid NOT IN (select clientuserid from watchlist)"
res = assert (con:execute(sql))
logme("removed " .. res .. " records for users not on the watchlist.")
@@ -581,7 +581,7 @@ local parsedglog = function(logdata)
if logentry.shortreason == "" then logentry.shortreason = logentry.reason end
logentry.score = string.match(logentry.reason, "^.*: ([0-9]+) ")
logentry.logdatetime = string.gsub(logentry.logdatetime, "%.", "-")
-
+
logentries[#logentries+1] = logentry
end
end
@@ -1022,7 +1022,7 @@ function deletewatchlistent(clientuserid)
if not res and err then
result.errtxt = result.errtxt .. "\n" .. err
end
-
+
return result
end
@@ -1177,19 +1177,19 @@ local function validateconfig(newconfig)
elseif not validator.is_integer(newconfig.value.window.value) then
newconfig.value.window.errtxt = "Must be a number"
success = false
- end
+ end
if not validator.is_integer(newconfig.value.watchdays.value) then
newconfig.value.watchdays.errtxt = "Must be a number"
success = false
- end
+ end
if not validator.is_integer(newconfig.value.purgedays.value) then
newconfig.value.purgedays.errtxt = "Must be a number"
success = false
- end
+ end
if not validator.is_integer(newconfig.value.historydays.value) then
newconfig.value.historydays.errtxt = "Must be a number"
success = false
- end
+ end
local res, err = pcall(function()
databaseconnect(DatabaseUser)
local s
@@ -1221,7 +1221,7 @@ function updateconfig(newconfig)
configcontent = format.update_ini_file(configcontent, "", "purgedays", newconfig.value.purgedays.value)
configcontent = format.update_ini_file(configcontent, "", "historydays", newconfig.value.historydays.value)
configcontent = format.update_ini_file(configcontent, "", "groupby", newconfig.value.groupby.value)
-
+
fs.write_file(configfile, configcontent)
config = format.parse_ini_file(configcontent, "") or {}
else
@@ -1348,7 +1348,7 @@ function create_database(database)
deletedatabase()
end
end
-
+
if not success then
database.errtxt = "Failed to create database"
if errtxt then