Esempio n. 1
0
 def setup_rotation(self) -> None:
     self.season_start_display = dtutil.display_date(seasons.last_rotation())
     self.season_end_display = dtutil.display_date(seasons.next_rotation())
     self.scryfall_url = 'https://scryfall.com/search?q=f%3Apd'
     self.legal_cards_url = 'http://pdmtgo.com/legal_cards.txt'
     self.in_rotation = rotation.in_rotation()
     self.rotation_msg = 'Rotation is in progress.'
     self.rotation_url = url_for('rotation')
def cleanup(count: int = 0) -> None:
    beginning_of_season = seasons.last_rotation()
    one_month_ago = dtutil.now(dtutil.WOTC_TZ) - datetime.timedelta(31)
    oldest_needed = min(beginning_of_season, one_month_ago)
    limit = ''
    if count > 0:
        limit = f'LIMIT {count * 2}'
    execute('DELETE FROM low_price WHERE `time` < %s ' + limit,
            [dtutil.dt2ts(oldest_needed)])
Esempio n. 3
0
def stats() -> Dict[str, int]:
    sql = """
        SELECT
            SUM(CASE WHEN FROM_UNIXTIME(`date`) >= NOW() - INTERVAL 1 DAY THEN 1 ELSE 0 END) AS num_matches_today,
            SUM(CASE WHEN FROM_UNIXTIME(`date`) >= NOW() - INTERVAL 7 DAY THEN 1 ELSE 0 END) AS num_matches_this_week,
            SUM(CASE WHEN FROM_UNIXTIME(`date`) >= NOW() - INTERVAL 30 DAY THEN 1 ELSE 0 END) AS num_matches_this_month,
            SUM(CASE WHEN `date` >= %s THEN 1 ELSE 0 END) AS num_matches_this_season,
            COUNT(*) AS num_matches_all_time
        FROM
            `match`
    """
    return db().select(sql, [dtutil.dt2ts(seasons.last_rotation())])[0]
def kick_off_date() -> datetime.datetime:
    start_of_season = seasons.last_rotation()
    return start_of_season + datetime.timedelta(days=8, hours=13, minutes=30)  # This effectively hardcodes a 10:30 PD Sat start time AND a Thu/Fri midnight rotation time.