don't use admin field in db anymore
This commit is contained in:
parent
aff6e426eb
commit
30ed9e2076
3 changed files with 8 additions and 8 deletions
|
|
@ -37,7 +37,6 @@ create table if not exists person(
|
|||
creation timestamp not null default (DATETIME('now')),
|
||||
salt varbin(128) not null,
|
||||
status varchar(30) not null,
|
||||
admin bool default false,
|
||||
lastOnline timestamp not null default (DATETIME('now'))
|
||||
);""" % [TUserName, TPassword, TEmail]), [])
|
||||
# echo "person table already exists"
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ var db = open(connection="nimforum.db", user="postgres", password="",
|
|||
db.exec(sql("update person set status = ?"), $User)
|
||||
db.exec(sql("update person set status = ? where ban <> ''"), $Troll)
|
||||
db.exec(sql("update person set status = ? where ban like '%spam%'"), $Spammer)
|
||||
db.exec(sql("update person set status = ? where admin"), $Admin)
|
||||
db.exec(sql("update person set status = ? where ban = 'DEACTIVATED' or ban = 'EMAILCONFIRMATION'"), $Inactive)
|
||||
db.exec(sql("update person set status = ? where admin = 'true'"), $Admin)
|
||||
|
||||
close(db)
|
||||
|
|
|
|||
12
forum.nim
12
forum.nim
|
|
@ -58,8 +58,8 @@ type
|
|||
totalUsers: int
|
||||
totalPosts: int
|
||||
totalThreads: int
|
||||
newestMember: tuple[nick: string, id: int, isAdmin: bool]
|
||||
activeUsers: seq[tuple[nick: string, id: int, isAdmin: bool]]
|
||||
newestMember: tuple[nick: string, id: int]
|
||||
activeUsers: seq[tuple[nick: string, id: int]]
|
||||
|
||||
TUserInfo = object
|
||||
nick: string
|
||||
|
|
@ -750,16 +750,16 @@ proc getStats(c: var TForumData, simple: bool): TForumStats =
|
|||
if not simple:
|
||||
var newestMemberCreation = 0
|
||||
result.activeUsers = @[]
|
||||
result.newestMember = ("", -1, false)
|
||||
result.newestMember = ("", -1)
|
||||
const getUsersQuery =
|
||||
sql"select id, name, admin, strftime('%s', lastOnline), strftime('%s', creation) from person"
|
||||
sql"select id, name, strftime('%s', lastOnline), strftime('%s', creation) from person"
|
||||
for row in fastRows(db, getUsersQuery):
|
||||
let secs = if row[3] == "": 0 else: row[3].parseint
|
||||
let lastOnlineSeconds = getTime() - Time(secs)
|
||||
if lastOnlineSeconds < (60 * 5): # 5 minutes
|
||||
result.activeUsers.add((row[1], row[0].parseInt, row[2].parseBool))
|
||||
result.activeUsers.add((row[1], row[0].parseInt))
|
||||
if row[4].parseInt > newestMemberCreation:
|
||||
result.newestMember = (row[1], row[0].parseInt, row[2].parseBool)
|
||||
result.newestMember = (row[1], row[0].parseInt)
|
||||
newestMemberCreation = row[4].parseInt
|
||||
|
||||
proc genPagenumNav(c: var TForumData, stats: TForumStats): string =
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue