Example #1
0
File: comment.py Project: CMGS/ymir
def delete_comments_by_tid(site, tid):
    comment_table = get_table(site.id, site.token, site.node)
    result = comment_table.delete().where(comment_table.tid == tid).execute()
    site.comments = Site.comments - result
    site.save()
    rds.decr(config.COMMENT_COUNT_PREFIX.format(sid = site.id, tid = tid), result)
    return result
Example #2
0
File: comment.py Project: CMGS/ymir
def delete_comment(site, comment):
    comment_table = get_table(site.id, site.token, site.node)
    comment.delete_instance()
    result = comment_table.delete().where(comment_table.fid == comment.id).execute()
    need_delete_keys = [config.COMMENT_CACHE_PREFIX.format(sid = site.id, id = comment.id)]
    if comment.fid:
        f_comment = get_comment(site, comment.fid)
        f_comment.count = comment_table.count - 1
        f_comment.save()
        need_delete_keys.append(config.COMMENT_CACHE_PREFIX.format(sid = site.id, id = comment.fid))
    result += 1
    site.comments = Site.comments - result
    site.save()
    rds.delete(*need_delete_keys)
    rds.decr(config.COMMENT_COUNT_PREFIX.format(sid = site.id, tid = comment.tid), result)
    return result