diff options
author | Egil Moeller <egil.moller@freecode.no> | 2010-04-12 19:56:19 +0200 |
---|---|---|
committer | Egil Moeller <egil.moller@freecode.no> | 2010-04-12 19:56:19 +0200 |
commit | f509fce5e7c45299a7798ae1dc0d731eb1eaf1cb (patch) | |
tree | bb56352d4c9a67bc9c7a361bd45e347ffba520af | |
parent | 1e3c76c56eccd9010f99c8daddd1a8ab31cb83db (diff) | |
download | etherpad-f509fce5e7c45299a7798ae1dc0d731eb1eaf1cb.tar.gz etherpad-f509fce5e7c45299a7798ae1dc0d731eb1eaf1cb.tar.xz etherpad-f509fce5e7c45299a7798ae1dc0d731eb1eaf1cb.zip |
Moved some more stuff to the model
-rw-r--r-- | etherpad/src/plugins/twitterStyleTags/controllers/tagBrowser.js | 20 | ||||
-rw-r--r-- | etherpad/src/plugins/twitterStyleTags/models/tagQuery.js | 28 |
2 files changed, 30 insertions, 18 deletions
diff --git a/etherpad/src/plugins/twitterStyleTags/controllers/tagBrowser.js b/etherpad/src/plugins/twitterStyleTags/controllers/tagBrowser.js index 838fb24..ac0d949 100644 --- a/etherpad/src/plugins/twitterStyleTags/controllers/tagBrowser.js +++ b/etherpad/src/plugins/twitterStyleTags/controllers/tagBrowser.js @@ -54,24 +54,8 @@ function onRequest() { var queryNewTagsSql = tagQuery.newTagsSql(querySql); var newTags = sqlobj.executeRaw(queryNewTagsSql.sql, queryNewTagsSql.params); - /* Select the 10 last changed matching pads and some extra information on them. Except the Pro Pads*/ - var sql = '' + - 'select ' + - ' m.id as ID, ' + - ' DATE_FORMAT(m.lastWriteTime, \'%a, %d %b %Y %H:%i:%s GMT\') as lastWriteTime, ' + - ' c.TAGS ' + - 'from ' + - querySql.sql + ' as q ' + - ' join PAD_SQLMETA as m on ' + - ' m.id = q.ID ' + - ' join PAD_TAG_CACHE as c on ' + - ' c.PAD_ID = q.ID ' + - 'where ' + - ' m.id NOT LIKE \'%$%\'' + - 'order by ' + - ' m.lastWriteTime desc ' + - 'limit 10'; - var matchingPads = sqlobj.executeRaw(sql, querySql.params); + padSql = tagQuery.padInfoSql(querySql, 10); + var matchingPads = sqlobj.executeRaw(padSql.sql, padSql.params); for (i = 0; i < matchingPads.length; i++) { matchingPads[i].TAGS = matchingPads[i].TAGS.split('#'); diff --git a/etherpad/src/plugins/twitterStyleTags/models/tagQuery.js b/etherpad/src/plugins/twitterStyleTags/models/tagQuery.js index a2e8374..8665b96 100644 --- a/etherpad/src/plugins/twitterStyleTags/models/tagQuery.js +++ b/etherpad/src/plugins/twitterStyleTags/models/tagQuery.js @@ -180,3 +180,31 @@ function newTagsSql(querySql) { '', info), params: queryNrParams.concat(queryParams)}; } + +/* Select the X last changed matching pads and some extra information + * on them. Except the Pro Pads*/ +function padInfoSql(querySql, limit, offset) { + var sql = '' + + 'select ' + + ' m.id as ID, ' + + ' DATE_FORMAT(m.lastWriteTime, \'%a, %d %b %Y %H:%i:%s GMT\') as lastWriteTime, ' + + ' c.TAGS ' + + 'from ' + + querySql.sql + ' as q ' + + ' join PAD_SQLMETA as m on ' + + ' m.id = q.ID ' + + ' join PAD_TAG_CACHE as c on ' + + ' c.PAD_ID = q.ID ' + + 'where ' + + ' m.id NOT LIKE \'%$%\'' + + 'order by ' + + ' m.lastWriteTime desc '; + if (limit != undefined) + sql += 'limit ' + limit + " "; + if (offset != undefined) + sql += 'offset ' + offset + " "; + return { + sql: sql, + params: querySql.params + }; +} |