'Loads show and episode statistics from db'

@staticmethod
def show_statistics():

    main_db_con = db.DBConnection()
    today = str(datetime.date.today().toordinal())
    status_quality = ((u'(' + u','.join([str(x) for x in ((Quality.SNATCHED + Quality.SNATCHED_PROPER) + Quality.SNATCHED_BEST)])) + u')')
    status_download = ((u'(' + u','.join([str(x) for x in (Quality.DOWNLOADED + Quality.ARCHIVED)])) + u')')
    sql_statement = u'SELECT    showid,'
    sql_statement += ((u'    (SELECT    COUNT(*)    FROM    tv_episodes    WHERE    showid=tv_eps.showid    AND    season    >    0    AND    episode    >    0    AND    airdate    >    1    AND    status    IN    ' + status_quality) + u')    AS    ep_snatched,')
    sql_statement += ((u'    (SELECT    COUNT(*)    FROM    tv_episodes    WHERE    showid=tv_eps.showid    AND    season    >    0    AND    episode    >    0    AND    airdate    >    1    AND    status    IN    ' + status_download) + u')    AS    ep_downloaded,')
    sql_statement += u'    (SELECT    COUNT(*)    FROM    tv_episodes    WHERE    showid=tv_eps.showid    AND    season    >    0    AND    episode    >    0    AND    airdate    >    1'
    sql_statement += ((((u'    AND    ((airdate    <=    ' + today) + u'    AND    status    IN    (') + u','.join([str(SKIPPED), str(WANTED), str(FAILED)])) + u'))')
    sql_statement += ((((u'    OR    (status    IN    ' + status_quality) + u')    OR    (status    IN    ') + status_download) + u')))    AS    ep_total,')
    sql_statement += (u'    (SELECT    airdate    FROM    tv_episodes    WHERE    showid=tv_eps.showid    AND    airdate    >=    ' + today)
    sql_statement += ((((u'    AND    season    >    0', u'')[sickbeard.DISPLAY_SHOW_SPECIALS] + u'    AND    status    IN    (') + u','.join([str(UNAIRED), str(WANTED)])) + u')')
    sql_statement += u'    ORDER    BY    airdate    ASC    LIMIT    1)    AS    ep_airs_next,'
    sql_statement += u'    (SELECT    airdate    FROM    tv_episodes    WHERE    showid=tv_eps.showid    AND    airdate    >    1'
    sql_statement += (((u'    AND    season    >    0', u'')[sickbeard.DISPLAY_SHOW_SPECIALS] + u'    AND    status    <>    ') + str(UNAIRED))
    sql_statement += u'    ORDER    BY    airdate    DESC    LIMIT    1)    AS    ep_airs_prev,'
    sql_statement += u'    (SELECT    SUM(file_size)    FROM    tv_episodes    WHERE    showid=tv_eps.showid)    AS    show_size'
    sql_statement += u'    FROM    tv_episodes    tv_eps    GROUP    BY    showid'
    sql_result = main_db_con.select(sql_statement)
    show_stat = {}
    max_download_count = 1000
    for cur_result in sql_result:
        show_stat[cur_result['showid']] = cur_result
        if (cur_result['ep_total'] > max_download_count):
            max_download_count = cur_result['ep_total']
    max_download_count *= 100
    return (show_stat, max_download_count)
