model.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:forget 作者: codl 项目源码 文件源码
def estimate_eligible_for_delete(self):
        """
        this is an estimation because we do not know if favourite status has
        changed since last time a post was refreshed and it is unfeasible to
        refresh every single post every time we need to know how many posts are
        eligible to delete
        """
        latest_n_posts = (Post.query.with_parent(self)
                          .order_by(db.desc(Post.created_at))
                          .limit(self.policy_keep_latest))
        query = (Post.query.with_parent(self)
                 .filter(Post.created_at <=
                         db.func.now() - self.policy_keep_younger)
                 .except_(latest_n_posts))
        if(self.policy_keep_favourites):
            query = query.filter(db.or_(Post.favourite == False, Post.is_reblog))
        if(self.policy_keep_media):
            query = query.filter(db.or_(Post.has_media == False, Post.is_reblog))
        if(self.policy_keep_direct):
            query = query.filter(~Post.direct)
        return query.count()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号