summaryrefslogtreecommitdiff
path: root/lib/db
diff options
context:
space:
mode:
authorJules <jules@asdf.us>2018-04-02 10:17:32 -0400
committerJules <jules@asdf.us>2018-04-02 10:17:32 -0400
commitf886ab318b4bde2063c4319c49bf98b5146fa639 (patch)
tree6cfcb99a775ee36775c203d6a31fcd43d1e68e4b /lib/db
parent3f408d626fa84d0d571e414932e8ac755e24800d (diff)
im_cmd counts api
Diffstat (limited to 'lib/db')
-rw-r--r--lib/db/index.js12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/db/index.js b/lib/db/index.js
index 6e36602..a9e29be 100644
--- a/lib/db/index.js
+++ b/lib/db/index.js
@@ -46,3 +46,15 @@ db.createImage = function(url){
db.createShaderImage = function(data){
return new ShaderImage(data).save()
}
+// select name,dir,newfile,count(*) as count from im_cmd where tag='ascii' group by name order by count desc;
+db.getUserCounts = function(){
+ return knex.column('name').column('dir').column('newfile').count('* as count').from('im_cmd').where('tag','ascii').groupBy('name').orderBy(knex.raw('count'), 'desc')
+}
+db.getLatestByUser = function(){
+ return knex.max('id as id').count('* as count').column('name').from('im_cmd').where('tag','ascii').groupBy('name').orderBy('count', 'desc')
+ // raw('SELECT MAX(id) as id, COUNT(*) as count, name FROM im_cmd WHERE tag='ascii' GROUP BY name')
+}
+db.getPhotoblasterImages = function(ids) {
+ return ShaderImage.query(qb => { return qb.where('id', 'in', ids) }).fetchAll()
+}
+