helper.py 文件源码

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

项目:insomnia-app 作者: k-wiz 项目源码 文件源码
def frequency_insomnia_type(user_id, start_date, end_date, insom_type):
    """Returns count of occurrence of insom_type from start_date to end_date."""

    frequency_type = db.session.query(Entry.insom_type, db.func.count\
                            (Entry.insom_type)).filter(Entry.user_id == user_id,\
                            Entry.date >= start_date, Entry.date <= end_date, \
                            Entry.insom_type == insom_type).\
                            group_by(Entry.insom_type).all()

    if len(frequency_type) != 0:
        return frequency_type[0][1]
    else:
        return 0
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号