helper.py 文件源码

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

项目:insomnia-app 作者: k-wiz 项目源码 文件源码
def integer_type_data(user_id, start_date, end_date, column_name):
    """Returns a tuple of lists, one list of dates as strings, and one list of 
    data points as integers. column_name should be an object with attribute
    column_name, e.g. Entry.stress_level."""

    data_points = sorted(db.session.query(Entry.date, column_name).filter\
        (Entry.user_id == user_id, Entry.date >= start_date, 
        Entry.date <= end_date).all())

    dates = []
    scores = []

    for item in data_points:
        date = "%s/%s" % (item[0].month, item[0].day)
        dates.append(date)

        score = item[1]
        scores.append(score)

    return dates, scores
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号