Exemple #1
0
 def get(self):
     logger = logging.getLogger('MatchupHistory')            
     ea_id = self.get_argument('ea_id') 
     try:
         club = get_clubs(ea_id=ea_id)
         if len(club) == 0:
             import_games(ea_id, 0, 0)
         else:
             club = club[0]
             most_recent_game = club.get_games(1)[0]
             dt = datetime.datetime.fromtimestamp(float(most_recent_game.ea_page_timestamp))
             days_from_start = (dt - datetime.datetime.fromtimestamp(float(earliest_timestamp))).days - 1
             import_games(club.ea_id, days_from_start, 0)
         result_str = 'success'
     except Exception, e:
         logger.exception(e)
         Session().rollback()
         result_str = e.message
Exemple #2
0
from gamelistscraper import import_games, earliest_timestamp
from models import get_clubs
from sqlalchemy.sql.functions import current_date
import datetime
import logging
#
logger = logging.getLogger('ImportJob')
d = datetime.datetime.now()
if d.hour in range (0, 8) or d.hour in range(22,25):#only run during these hours (heroku server seems to be eastern + 4?)
    if d.minute in range(0, 10) or d.minute in range(20,30) or d.minute in range(40,50):
        our_club = get_clubs(1)[0]
        most_recent_game = our_club.get_games(1)[0]
        dt = datetime.datetime.fromtimestamp(float(most_recent_game.ea_page_timestamp))
        days_from_start = (dt - datetime.datetime.fromtimestamp(float(earliest_timestamp))).days - 1
        import_games(our_club.ea_id, days_from_start, 0)
    else:
        logger.info('Skipping import because minutes are %d' % d.minute)
else:
    logger.info('Skipping import because hour is %d' % d.hour)