diff options
Diffstat (limited to 'bucky/db/index.js')
| -rw-r--r-- | bucky/db/index.js | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/bucky/db/index.js b/bucky/db/index.js index 53e36dd..312ca13 100644 --- a/bucky/db/index.js +++ b/bucky/db/index.js @@ -55,7 +55,7 @@ db.createUser = function(data){ } db.getUsers = function () { return User.query(function(qb){ - qb.orderBy("username", "desc") + qb.orderBy("username", "asc") }).fetchAll({ columns: [ "id", "username", "realname", "firstseen", "lastseen", @@ -148,6 +148,15 @@ db.getThreadUsers = function(thread_id){ db.getUserThreadIds = function(user_id){ return ThreadUser.query("where", "user_id", "=", user_id).fetch() } +db.getUserThreadCounts = function(ids){ + return knex.column('username').count('* as count').select().from('threads').groupBy('username') +} +db.getUserCommentCounts = function(ids){ + return knex.column('username').count('* as count').select().from('comments').groupBy('username') +} +db.getUserFileCounts = function(ids){ + return knex.column('username').sum('size as size').count('* as count').select().from('files').groupBy('username') +} /* FILES */ |
