Пример #1
0
def get_us_cpm_avg_by_date():
    if request.method == "GET":
        date = utils.get_date_from_args()
        window = utils.get_window_from_args()
        res = db.get_us_cpm_avg_by_date(date, window)
        return res
    raise exceptions.InvalidRequestException(request.method)
Пример #2
0
def get_world_hashtags(countryCode):
    if request.method == "GET":
        if utils.validate_country_code(countryCode):
            date = utils.get_date_from_args()
            res = db.get_hashtags_by_country(countryCode, date)
            return res
        raise exceptions.InvalidCountryException(countryCode)
    raise exceptions.InvalidRequestException(request.method)
Пример #3
0
def get_by_country(countryCode):
    """
    on GET request, if countryCode is valid, return
    document matching countryCode at the date supplied
    in the arguments

    If countryCode is invalid, respond with code 404
    and present error page

    On any other request respond with code 405
    """
    if request.method == "GET":
        date = utils.get_date_from_args()
        if (utils.validate_country_code(countryCode)):
            res = db.get_by_country_and_date(countryCode, date)
            return res
        raise exceptions.InvalidCountryException(countryCode)
    raise exceptions.InvalidRequestException(request.method)
Пример #4
0
def get_dpm_by_state(stateCode, methods=["GET"]):
    """
    on GET request, if stateCode is valid, return
    document matching stateCode at the date supplied
    in the arguments

    If stateCode is invalid, respond with code 404
    and present error page

    On any other request respond with code 405
    """
    if request.method == "GET":
        date = utils.get_date_from_args()
        if (utils.validate_state_code(stateCode)):
            res = db.get_dpm_by_state_and_date(stateCode, date)
            return res
        raise exceptions.InvalidStateException(stateCode)
    raise exceptions.InvalidRequestException(request.method)
Пример #5
0
def get_world_cpm_by_date():
    if request.method == "GET":
        date = utils.get_date_from_args()
        res = db.get_world_cpm_by_date(date)
        return res
    raise exceptions.InvalidRequestException(request.method)