]> git.ipfire.org Git - ipfire.org.git/blobdiff - src/backend/blog.py
Add bot that automatically tweets some things
[ipfire.org.git] / src / backend / blog.py
index de2b8b69f55251a4a3f815ca4b30779c0ca05730..e79dd308f2cad6ae5352b8185ff8ff9e3ff25ce8 100644 (file)
@@ -98,6 +98,18 @@ class Blog(misc.Object):
                                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