views.py 文件源码

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

项目:automated-reporting 作者: Waikato 项目源码 文件源码
def get_max_years():
    """
    Determines the maximum number of available years to go back.

    :return: the number of years
    :rtype: int
    """

    cursor = connection.cursor()
    cursor.execute("""
        select extract(year from min(start_date))
        from %s
        where start_date > '1900-01-01'
        """ % StudentDates._meta.db_table)
    min_year = None
    max_years = None
    for row in cursor.fetchall():
        min_year = row[0]
    if min_year is not None:
        max_years = date.today().year - min_year

    return int(max_years)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号