• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python vault.get_user_from_runtime_storage函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中stackalytics.dashboard.vault.get_user_from_runtime_storage函数的典型用法代码示例。如果您正苦于以下问题:Python get_user_from_runtime_storage函数的具体用法?Python get_user_from_runtime_storage怎么用?Python get_user_from_runtime_storage使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_user_from_runtime_storage函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: get_users_json

def get_users_json(record_ids, **kwargs):
    core_in = parameters.get_single_parameter(kwargs, 'core_in') or None
    valid_modules = set()
    if core_in:
        core_in = set(core_in.split(','))
        valid_modules = vault.resolve_project_types(
            kwargs['_params']['project_type'])
        valid_modules = set(m[0] for m in vault.resolve_modules(
            valid_modules, kwargs['_params']['release']))

    user_ids = vault.get_memory_storage().get_index_keys_by_record_ids(
        'user_id', record_ids)
    if kwargs['_params']['user_id']:
        user_ids.add(kwargs['_params']['user_id'][0])

    result = []
    for user_id in user_ids:
        user = vault.get_user_from_runtime_storage(user_id)
        r = {'id': user_id, 'text': user['user_name']}

        add_flag = not core_in
        if core_in and user.get('core'):
            core_modules = [module_branch[0] for module_branch in user['core']
                            if (module_branch[1] in core_in and
                                module_branch[0] in valid_modules)]
            if core_modules:
                r['core'] = core_modules
                if user['companies']:
                    r['company_name'] = user['companies'][-1]['company_name']
                add_flag = True
        if add_flag:
            result.append(r)

    result.sort(key=lambda x: x['text'])
    return result
开发者ID:liujunpengwork,项目名称:stackalytics,代码行数:35,代码来源:web.py


示例2: postprocessing

    def postprocessing(record):
        record = decorators.mark_finalize(record)

        if not (record['mark'] or record['review'] or record['commit'] or
                record['email'] or record['patch']):
            return

        user = vault.get_user_from_runtime_storage(record['id'])
        record['company'] = user['companies'][-1]['company_name']
        record['core'] = get_core_engineer_branch(user, modules)
        return record
开发者ID:dlundquist,项目名称:stackalytics,代码行数:11,代码来源:web.py


示例3: user_activity

def user_activity(user_id):
    user = vault.get_user_from_runtime_storage(user_id)
    if not user:
        flask.abort(404)
    user = helpers.extend_user(user)

    memory_storage_inst = vault.get_memory_storage()
    result = _get_activity_summary(
        memory_storage_inst.get_record_ids_by_user_ids([user_id]))
    result['user'] = user

    return result
开发者ID:Youngcoder,项目名称:stackalytics,代码行数:12,代码来源:reports.py


示例4: get_users_json

def get_users_json(record_ids, **kwargs):
    user_ids = vault.get_memory_storage().get_index_keys_by_record_ids(
        'user_id', record_ids)
    if kwargs['_params']['user_id']:
        user_ids.add(kwargs['_params']['user_id'][0])

    result = [{'id': user_id,
               'text': (vault.get_user_from_runtime_storage(user_id)
                        ['user_name'])}
              for user_id in user_ids]

    result.sort(key=lambda x: x['text'])
    return result
开发者ID:dlundquist,项目名称:stackalytics,代码行数:13,代码来源:web.py


示例5: person_day_filter

def person_day_filter(result, record, param_id, context):
    if record['record_type'] == 'commit' or record['record_type'] == 'member':
        # 1. commit is attributed with the date of the merge which is not an
        # effort of the author (author's effort is represented in patches)
        # 2. registration on openstack.org is not an effort
        return

    day = utils.timestamp_to_day(record['date'])
    # fact that record-days are grouped by days in some order is used
    if context.get('last_processed_day') != day:
        context['last_processed_day'] = day
        context['counted_user_ids'] = set()

    user = vault.get_user_from_runtime_storage(record['user_id'])
    user_id = user['seq']

    value = record[param_id]
    if user_id not in context['counted_user_ids']:
        context['counted_user_ids'].add(user_id)
        result[value]['metric'] += 1
开发者ID:dlundquist,项目名称:stackalytics,代码行数:20,代码来源:decorators.py


示例6: make_page_title

def make_page_title(company, user_id, module, release):
    if company:
        memory_storage = vault.get_memory_storage()
        company = memory_storage.get_original_company_name(company)
    if company or user_id:
        if user_id:
            s = vault.get_user_from_runtime_storage(user_id)['user_name']
            if company:
                s += ' (%s)' % company
        else:
            s = company
    else:
        s = 'OpenStack community'
    s += ' contribution'
    if module:
        s += ' to %s' % module
    if release != 'all':
        s += ' in %s release' % release.capitalize()
    else:
        s += ' in all releases'
    return s
开发者ID:dlundquist,项目名称:stackalytics,代码行数:21,代码来源:helpers.py


示例7: timeline

def timeline(records, **kwargs):
    # find start and end dates
    metric = parameters.get_parameter(kwargs, 'metric')
    start_date = int(parameters.get_single_parameter(kwargs, 'start_date')
                     or 0)
    release_name = parameters.get_single_parameter(kwargs, 'release') or 'all'
    releases = vault.get_vault()['releases']

    if 'all' in release_name:
        start_week = release_start_week = _get_week(kwargs, 'start_date')
        end_week = release_end_week = _get_week(kwargs, 'end_date')
    else:
        release = releases[release_name]
        start_week = release_start_week = utils.timestamp_to_week(
            release['start_date'])
        end_week = release_end_week = utils.timestamp_to_week(
            release['end_date'])

    now = utils.timestamp_to_week(int(time.time())) + 1

    # expand start-end to year if needed
    if release_end_week - release_start_week < 52:
        expansion = (52 - (release_end_week - release_start_week)) // 2
        if release_end_week + expansion < now:
            end_week += expansion
        else:
            end_week = now
        start_week = end_week - 52

    # empty stats for all weeks in range
    weeks = range(start_week, end_week)
    week_stat_loc = dict((c, 0) for c in weeks)
    week_stat_commits = dict((c, 0) for c in weeks)
    week_stat_commits_hl = dict((c, 0) for c in weeks)

    if ('commits' in metric) or ('loc' in metric):
        handler = lambda record: record['loc']
    else:
        handler = lambda record: 0

    # fill stats with the data
    if 'person-day' in metric:
        # special case for man-day effort metric
        release_stat = collections.defaultdict(set)
        all_stat = collections.defaultdict(set)
        for record in records:
            if ((record['record_type'] in ['commit', 'member']) or
                    (record['week'] not in weeks)):
                continue

            day = utils.timestamp_to_day(record['date'])
            user = vault.get_user_from_runtime_storage(record['user_id'])
            if record['release'] == release_name:
                release_stat[day] |= set([user['seq']])
            all_stat[day] |= set([user['seq']])
        for day, users in six.iteritems(release_stat):
            week = utils.timestamp_to_week(day * 24 * 3600)
            week_stat_commits_hl[week] += len(users)
        for day, users in six.iteritems(all_stat):
            week = utils.timestamp_to_week(day * 24 * 3600)
            week_stat_commits[week] += len(users)
    else:
        for record in records:
            week = record['week']
            if week in weeks:
                week_stat_loc[week] += handler(record)
                week_stat_commits[week] += 1
                if 'members' in metric:
                    if record['date'] >= start_date:
                        week_stat_commits_hl[week] += 1
                else:
                    if record['release'] == release_name:
                        week_stat_commits_hl[week] += 1

    if 'all' == release_name and 'members' not in metric:
        week_stat_commits_hl = week_stat_commits

    # form arrays in format acceptable to timeline plugin
    array_loc = []
    array_commits = []
    array_commits_hl = []

    for week in weeks:
        week_str = utils.week_to_date(week)
        array_loc.append([week_str, week_stat_loc[week]])
        array_commits.append([week_str, week_stat_commits[week]])
        array_commits_hl.append([week_str, week_stat_commits_hl[week]])

    return [array_commits, array_commits_hl, array_loc]
开发者ID:dlundquist,项目名称:stackalytics,代码行数:89,代码来源:web.py


示例8: get_user

def get_user(user_id):
    user = vault.get_user_from_runtime_storage(user_id)
    if not user:
        flask.abort(404)
    user = helpers.extend_user(user)
    return user
开发者ID:dlundquist,项目名称:stackalytics,代码行数:6,代码来源:web.py


示例9: templated_decorated_function

        def templated_decorated_function(*args, **kwargs):

            vault_inst = vault.get_vault()
            template_name = template
            if template_name is None:
                template_name = (flask.request.endpoint.replace('.', '/') +
                                 '.html')
            ctx = f(*args, **kwargs)
            if ctx is None:
                ctx = {}

            # put parameters into template
            metric = flask.request.args.get('metric')
            if metric not in parameters.METRIC_LABELS:
                metric = None
            ctx['metric'] = metric or parameters.get_default('metric')
            ctx['metric_label'] = parameters.METRIC_LABELS[ctx['metric']]

            project_type = flask.request.args.get('project_type')
            if not vault.is_project_type_valid(project_type):
                project_type = parameters.get_default('project_type')
            ctx['project_type'] = project_type

            release = flask.request.args.get('release')
            releases = vault_inst['releases']
            if release:
                release = release.lower()
                if release != 'all':
                    if release not in releases:
                        release = None
                    else:
                        release = releases[release]['release_name']
            ctx['release'] = (release or
                              parameters.get_default('release')).lower()
            ctx['review_nth'] = (flask.request.args.get('review_nth') or
                                 parameters.get_default('review_nth'))

            ctx['company'] = parameters.get_single_parameter(kwargs, 'company')
            ctx['company_original'] = (
                vault.get_memory_storage().get_original_company_name(
                    ctx['company']))

            module = parameters.get_single_parameter(kwargs, 'module')
            ctx['module'] = module
            module_name = None
            if module and module in vault_inst['module_id_index']:
                ctx['module_inst'] = vault_inst['module_id_index'][module]
                module_name = ctx['module_inst']['module_group_name']

            ctx['user_id'] = parameters.get_single_parameter(kwargs, 'user_id')
            if ctx['user_id']:
                ctx['user_inst'] = vault.get_user_from_runtime_storage(
                    ctx['user_id'])
            ctx['page_title'] = helpers.make_page_title(
                ctx['company'], ctx['user_id'], module_name, ctx['release'])
            ctx['stackalytics_version'] = (
                stackalytics_version.version_info.version_string())
            ctx['stackalytics_release'] = (
                stackalytics_version.version_info.release_string())
            ctx['runtime_storage_update_time'] = (
                vault_inst['runtime_storage_update_time'])

            return flask.render_template(template_name, **ctx), return_code
开发者ID:dims,项目名称:stackalytics,代码行数:63,代码来源:decorators.py


示例10: record_filter_decorated_function

        def record_filter_decorated_function(*args, **kwargs):

            memory_storage_inst = vault.get_memory_storage()
            record_ids = None

            params = _prepare_params(kwargs, ignore)

            release = params['release']
            if release:
                if 'all' not in release:
                    record_ids = (
                        memory_storage_inst.get_record_ids_by_releases(
                            c.lower() for c in release))

            project_type = params['project_type']
            mr = None
            if project_type:
                mr = set(vault.resolve_modules(vault.resolve_project_types(
                    project_type), release))

            module = params['module']
            if module:
                mr = _intersect(mr, set(vault.resolve_modules(
                    module, release)))

            if mr is not None:
                record_ids = _intersect(
                    record_ids, _filter_records_by_modules(
                        memory_storage_inst, mr))

            user_id = params['user_id']
            user_id = [u for u in user_id
                       if vault.get_user_from_runtime_storage(u)]
            if user_id:
                record_ids = _intersect(
                    record_ids,
                    memory_storage_inst.get_record_ids_by_user_ids(user_id))

            company = params['company']
            if company:
                record_ids = _intersect(
                    record_ids,
                    memory_storage_inst.get_record_ids_by_companies(company))

            metric = params['metric']
            if 'all' not in metric:
                for metric in metric:
                    if metric in parameters.METRIC_TO_RECORD_TYPE:
                        record_ids = _intersect(
                            record_ids,
                            memory_storage_inst.get_record_ids_by_type(
                                parameters.METRIC_TO_RECORD_TYPE[metric]))

            if 'tm_marks' in metric:
                filtered_ids = []
                review_nth = int(parameters.get_parameter(
                    kwargs, 'review_nth')[0])
                for record in memory_storage_inst.get_records(record_ids):
                    parent = memory_storage_inst.get_record_by_primary_key(
                        record['review_id'])
                    if (parent and ('review_number' in parent) and
                            (parent['review_number'] <= review_nth)):
                        filtered_ids.append(record['record_id'])
                record_ids = filtered_ids

            blueprint_id = params['blueprint_id']
            if blueprint_id:
                record_ids = _intersect(
                    record_ids,
                    memory_storage_inst.get_record_ids_by_blueprint_ids(
                        blueprint_id))

            start_date = params['start_date']
            end_date = params['end_date']

            if start_date or end_date:
                record_ids = _intersect(
                    record_ids, _filter_records_by_days(start_date, end_date,
                                                        memory_storage_inst))

            kwargs['record_ids'] = record_ids
            kwargs['records'] = memory_storage_inst.get_records(record_ids)

            return f(*args, **kwargs)
开发者ID:dims,项目名称:stackalytics,代码行数:84,代码来源:decorators.py


示例11: templated_decorated_function

        def templated_decorated_function(*args, **kwargs):

            vault_inst = vault.get_vault()
            template_name = template
            if template_name is None:
                template_name = (flask.request.endpoint.replace('.', '/') +
                                 '.html')
            ctx = f(*args, **kwargs)
            if ctx is None:
                ctx = {}

            try:
                _prepare_params(kwargs, [])
            except Exception:
                if return_code == 200:
                    raise  # do not re-raise on error page

            # put parameters into template
            ctx['metric'] = parameters.get_single_parameter(
                kwargs, 'metric', use_default=True)
            ctx['metric_label'] = parameters.METRIC_LABELS.get(ctx['metric'])

            project_type = parameters.get_single_parameter(
                kwargs, 'project_type', use_default=True)
            ctx['project_type'] = project_type
            ctx['project_type_inst'] = vault.get_project_type(project_type)

            ctx['release'] = parameters.get_single_parameter(
                kwargs, 'release', use_default=True)

            company = parameters.get_single_parameter(kwargs, 'company')
            ctx['company'] = company
            if company:
                ctx['company_original'] = (
                    vault.get_memory_storage().get_original_company_name(
                        ctx['company']))

            module = parameters.get_single_parameter(kwargs, 'module')
            ctx['module'] = module
            if module and module in vault_inst['module_id_index']:
                ctx['module_inst'] = vault_inst['module_id_index'][module]

            ctx['user_id'] = parameters.get_single_parameter(kwargs, 'user_id')
            if ctx['user_id']:
                ctx['user_inst'] = vault.get_user_from_runtime_storage(
                    ctx['user_id'])

            ctx['page_title'] = helpers.make_page_title(
                ctx['project_type_inst'],
                ctx.get('release'), ctx.get('module_inst'),
                ctx.get('company_original'), ctx.get('user_inst'))

            ctx['stackalytics_version'] = (
                stackalytics_version.version_info.version_string())
            ctx['stackalytics_release'] = (
                stackalytics_version.version_info.release_string())
            update_time = vault_inst['runtime_storage_update_time']
            ctx['runtime_storage_update_time'] = update_time
            ctx['runtime_storage_update_time_str'] = helpers.format_datetime(
                update_time) if update_time else None

            # deprecated -- top mentor report
            ctx['review_nth'] = parameters.get_single_parameter(
                kwargs, 'review_nth')

            return flask.render_template(template_name, **ctx), return_code
开发者ID:Youngcoder,项目名称:stackalytics,代码行数:66,代码来源:decorators.py



注:本文中的stackalytics.dashboard.vault.get_user_from_runtime_storage函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python vault.get_vault函数代码示例发布时间:2022-05-27
下一篇:
Python vault.get_memory_storage函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap