From a925aa3bc307a4921aeeed0c53a0ec5090ca667e Mon Sep 17 00:00:00 2001 From: Perception Date: Tue, 22 Dec 2020 16:46:57 -0800 Subject: [PATCH] Add more tag-related functions --- index.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 090dd6c..64c9f66 100644 --- a/index.js +++ b/index.js @@ -287,7 +287,7 @@ async function getCategories(db) { return cats2 } -async function getTagCloud(db, limit) { +async function getTagCloud(db, limit, offset=0) { const tags = db.prepare(` SELECT count(t.id) as c, t.name FROM article__tag a_t @@ -296,7 +296,8 @@ async function getTagCloud(db, limit) { GROUP BY t.id ORDER BY c DESC LIMIT @limit - `).all({ limit }) + OFFSET @offset + `).all({ limit, offset }) return tags } @@ -444,5 +445,8 @@ module.exports = { getArticleCounts, getArticlesByYearMonth, getArticlesByCategory, - countArticlesByCategory + countArticlesByCategory, + getArticlesByTag, + countArticlesByTag, + countTags }