ORDER BY ts_rank(search_index.document, to_tsquery('english', %s)) DESC \
LIMIT %s", query, query, limit)
+ def has_had_recent_activity(self, t=None):
+ if t is None:
+ t = datetime.timedelta(hours=24)
+
+ res = self.db.get("SELECT COUNT(*) AS count FROM blog \
+ WHERE published_at IS NOT NULL AND published_at >= NOW() - %s", t)
+
+ if res and res.count > 0:
+ return True
+
+ return False
+
def create_post(self, title, text, author, tags=[], lang="markdown"):
"""
Creates a new post and returns the resulting Post object