def create_query_params(**kwargs):
    params = {}
    for potential_arg in 'login', 'experiment_name', 'category_name', 'ip', 'country':
        if potential_arg in request.args:
            params[potential_arg] = request.args[potential_arg]

    for potential_arg in 'start_date', 'end_date':
        if potential_arg in request.args:
            try:
                params[potential_arg] = datetime.datetime.strptime(request.args[potential_arg], "%Y-%m-%d").date()
            except __HOLE__:
                pass

    for potential_arg in 'page',:
        if potential_arg in request.args:
            try:
                params[potential_arg] = int(request.args[potential_arg])
            except ValueError:
                pass

    if 'page' not in params or params['page'] <= 0:
        params['page'] = 1

    for potential_arg in 'date_precision',:
        if potential_arg in request.args:
            if request.args[potential_arg] in ('day', 'month', 'year', 'week'):
                params[potential_arg] = request.args[potential_arg]

    if 'date_precision' not in params:
        params['date_precision'] = 'month'
                
    params.update(kwargs)
    query_params = UsesQueryParams(**params)
    metadata = weblab_api.db.quickadmin_uses_metadata(query_params)
    params['count'] = metadata['count']

    if 'start_date' in params:
        params['min_date'] = params['start_date']
    else:
        params['min_date'] = metadata['min_date']

    if 'end_date' in params:
        params['max_date'] = params['end_date']
    else:
        params['max_date'] = metadata['max_date']

    return UsesQueryParams(**params)
dataset/ETHPy150Open weblabdeusto/weblabdeusto/server/src/weblab/core/web/quickadmin.py/create_query_params