Example #1
0
def update_questions_day(day_p):
    """ Loads data from a specific day into the database.
    """
    try:
        day = datetime.datetime.strptime(day_p, "%d/%m/%Y")
    except ValueError:
        print "Usage: python manager.py update_questions dd-mm-yyyy"
        exit(0)

    commands.update_questions(day)
Example #2
0
def get_data_api():
    """ We obtain data for one day only.
    """
    # Obtaining when the last data was downloaded
    fnc_max = func.max(Question.date).label("max")
    fnc_min = func.min(Question.date).label("min")
    dates = db_session.query(fnc_max, fnc_min).one()
    logger.debug("We have data in the database from `%s` to `%s`" % (dates.min, dates.max))
    next_day = dates.max + timedelta(days=1)
    yesterday = datetime.now().date() - timedelta(days=1)
    if next_day < yesterday:
        # If we have data before yesterday, we download data for that day
        # We download data for yesterday at midnight
        logger.info("Downloading data from API on day `%s`" % next_day)
        update_questions(next_day)
Example #3
0
def load_data_yesterday():
    """ We load from the api all questions from yesterday
    """
    update_questions()
Example #4
0
def update_questions_yesterday():
    """ Loads data from yesterday
    """
    commands.update_questions()