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
评论列表
文章目录