projects.py 文件源码

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

项目:FRG-Crowdsourcing 作者: 97amarnathk 项目源码 文件源码
def n_count(category):
    """Count the number of projects in a given category."""
    if category == 'featured':
        return _n_featured()
    if category == 'draft':
        return _n_draft()
    sql = text('''
               WITH uniq AS (
               SELECT COUNT(project.id) FROM project
               LEFT OUTER JOIN category ON project.category_id=category.id
               WHERE
               category.short_name=:category
               AND project.published=true
               AND (project.info->>'passwd_hash') IS NULL
               GROUP BY project.id)
               SELECT COUNT(*) FROM uniq
               ''')

    results = session.execute(sql, dict(category=category))
    count = 0
    for row in results:
        count = row[0]
    return count
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号