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)
+ def has_had_recent_activity(self, **kwargs):
+ t = datetime.timedelta(**kwargs)
res = self.db.get("SELECT COUNT(*) AS count FROM blog \
WHERE published_at IS NOT NULL AND published_at >= NOW() - %s", t)
Sends a random promotional tweet
"""
# Do not tweet too often
- if self.has_had_recent_activity():
+ if self.has_had_recent_activity(days=4):
logging.debug("Won't tweet because we recently did it")
return
# Do not tweet when there was a blog post
- if self.backend.blog.has_had_recent_activity():
+ if self.backend.blog.has_had_recent_activity(hours=24):
logging.debug("Won't tweet because the blog has had activity")
return
with self.db.transaction():
self._tweet(tweet)
- def has_had_recent_activity(self, t=None):
- if t is None:
- t = datetime.timedelta(days=4)
+ def has_had_recent_activity(self, **kwargs):
+ t = datetime.timedelta(**kwargs)
res = self.db.get("SELECT COUNT(*) AS count FROM tweets \
WHERE last_tweeted_at IS NOT NULL AND last_tweeted_at >= NOW() - %s", t)