Beispiel #1
0
def get_default(param_name):
    if 'release' not in DEFAULTS:
        release = cfg.CONF.default_release
        if not release:
            runtime_storage_inst = vault.get_runtime_storage()
            releases = runtime_storage_inst.get_by_key('releases')
            if releases:
                release = releases[-1]['release_name']
            else:
                release = 'all'
        DEFAULTS['release'] = release.lower()
        DEFAULTS['metric'] = cfg.CONF.default_metric.lower()
        DEFAULTS['project_type'] = cfg.CONF.default_project_type.lower()

    if param_name in DEFAULTS:
        return DEFAULTS[param_name]
    else:
        return None
Beispiel #2
0
def get_company_changes(**kwargs):

    start_days = str(
        flask.request.args.get('start_days')
        or utils.timestamp_to_date(int(time.time()) - 365 * 24 * 60 * 60))
    end_days = str(
        flask.request.args.get('end_days')
        or utils.timestamp_to_date(int(time.time())))

    start_date = utils.date_to_timestamp_ext(start_days)
    end_date = utils.date_to_timestamp_ext(end_days)

    runtime_storage = vault.get_runtime_storage()
    result = []

    for user in runtime_storage.get_all_users():
        companies = user.get('companies') or []
        if len(companies) < 2:
            continue

        companies_iter = iter(companies)
        company = companies_iter.next()
        old_company_name = company['company_name']
        date = company['end_date']

        for company in companies_iter:
            new_company_name = company['company_name']

            if start_date <= date <= end_date:
                result.append({
                    'user_id': user['user_id'],
                    'user_name': user['user_name'],
                    'old_company_name': old_company_name,
                    'new_company_name': new_company_name,
                    'date': date,
                })

            old_company_name = new_company_name
            date = company['end_date']

    return result
Beispiel #3
0
def get_company_changes(**kwargs):

    start_days = str(flask.request.args.get('start_days') or
                     utils.timestamp_to_date(int(time.time()) -
                                             365 * 24 * 60 * 60))
    end_days = str(flask.request.args.get('end_days') or
                   utils.timestamp_to_date(int(time.time())))

    start_date = utils.date_to_timestamp_ext(start_days)
    end_date = utils.date_to_timestamp_ext(end_days)

    runtime_storage = vault.get_runtime_storage()
    result = []

    for user in runtime_storage.get_all_users():
        companies = user.get('companies') or []
        if len(companies) < 2:
            continue

        companies_iter = iter(companies)
        company = companies_iter.next()
        old_company_name = company['company_name']
        date = company['end_date']

        for company in companies_iter:
            new_company_name = company['company_name']

            if start_date <= date <= end_date:
                result.append({
                    'user_id': user['user_id'],
                    'user_name': user['user_name'],
                    'old_company_name': old_company_name,
                    'new_company_name': new_company_name,
                    'date': date,
                })

            old_company_name = new_company_name
            date = company['end_date']

    return result
Beispiel #4
0
def get_default(param_name):
    if "release" not in DEFAULTS:
        release = cfg.CONF.default_release
        if not release:
            runtime_storage_inst = vault.get_runtime_storage()
            releases = runtime_storage_inst.get_by_key("releases")
            if releases:
                for r in releases:
                    if r["end_date"] > time.time():
                        release = r["release_name"]
                        break
                else:
                    release = releases[-1]["release_name"]
            else:
                release = "all"
        DEFAULTS["release"] = release.lower()
        DEFAULTS["metric"] = cfg.CONF.default_metric.lower()
        DEFAULTS["project_type"] = cfg.CONF.default_project_type.lower()

    if param_name in DEFAULTS:
        return DEFAULTS[param_name]
    else:
        return None