summaryrefslogtreecommitdiff
path: root/lib/db/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/db/index.js')
-rw-r--r--lib/db/index.js9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/db/index.js b/lib/db/index.js
index 3761417..8e72d34 100644
--- a/lib/db/index.js
+++ b/lib/db/index.js
@@ -67,13 +67,16 @@ db.getFilesForThread = function (id){
return File.query("where", "thread", "=", id).fetchAll()
}
db.getFileCounts = function(ids){
- return knex.column('thread', 'count(*)').select().from('comments').where('thread', 'in', ids).groupBy('thread')
+ return knex.column('thread').count('* as count').select().from('files').where('thread', 'in', ids).groupBy('thread')
+}
+db.getFileSizes = function(ids){
+ return knex.column('thread').sum('size as size').select().from('files').where('thread', 'in', ids).groupBy('thread')
}
/* COMMENTS */
db.getCommentsForThread = function (id){
return Comment.query("where", "thread", "=", id).fetchAll()
}
-db.getCommentCounts = function(){
- return knex.column('thread', 'count(*)').select().from('files').where('thread', 'in', ids).groupBy('thread')
+db.getCommentCounts = function(ids){
+ return knex.column('thread').count('* as count').select().from('comments').where('thread', 'in', ids).groupBy('thread')
}