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

Python utils.store_user函数代码示例

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

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



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

示例1: update_user

    def update_user(self, record):
        email = record.get('author_email')
        user_e = utils.load_user(self.runtime_storage_inst, email) or {}

        user_name = record.get('author_name')
        launchpad_id = record.get('launchpad_id')
        if email and (not user_e) and (not launchpad_id):
            # query LP
            launchpad_id, lp_user_name = self._get_lp_info(email)
            if lp_user_name:
                user_name = lp_user_name

        user_l = utils.load_user(self.runtime_storage_inst, launchpad_id) or {}

        user = self._create_user(launchpad_id, email, user_name)

        if (user_e.get('seq') == user_l.get('seq')) and user_e.get('seq'):
            # sequence numbers are set and the same, merge is not needed
            user = user_e
        else:
            if user_e or user_l:
                user = self._merge_user_profiles(user_e, user_l, user)
            else:
                # create new
                if not user_name:
                    user_name = self._get_lp_user_name(launchpad_id)
                    if user_name:
                        user['user_name'] = user_name
                LOG.debug('Created new user: %s', user)

            utils.store_user(self.runtime_storage_inst, user)

        return user
开发者ID:zasimov,项目名称:stackalytics,代码行数:33,代码来源:record_processor.py


示例2: _update_members_company_name

    def _update_members_company_name(self):
        LOG.debug('Update members with company names')

        for record in self.runtime_storage_inst.get_all_records():
            if record['record_type'] != 'member':
                continue

            company_draft = record['company_draft']
            company_name = self.domains_index.get(
                utils.normalize_company_name(company_draft)) or (
                    utils.normalize_company_draft(company_draft))

            if company_name == record['company_name']:
                continue

            LOG.debug('Update record %s, company name changed to %s',
                      record, company_name)
            record['company_name'] = company_name

            yield record

            user = utils.load_user(self.runtime_storage_inst,
                                   record['user_id'])
            LOG.debug('Update user %s, company name changed to %s',
                      user, company_name)
            user['companies'] = [{
                'company_name': company_name,
                'end_date': 0,
            }]
            utils.store_user(self.runtime_storage_inst, user)
开发者ID:blueboxjesse,项目名称:stackalytics,代码行数:30,代码来源:record_processor.py


示例3: update_user

    def update_user(self, record):
        email = record.get('author_email')

        user = utils.load_user(self.runtime_storage_inst, email)
        if not user:
            if record.get('launchpad_id'):
                launchpad_id = record.get('launchpad_id')
                user_name = record.get('author_name')
            else:
                launchpad_id, user_name = self._get_lp_info(email)

            if launchpad_id:
                user = utils.load_user(self.runtime_storage_inst, launchpad_id)

            if user:
                # merge emails
                if email:
                    self._update_user_profile(user, email)
            else:
                # create new
                if not user_name:
                    user_name = record.get('author_name')
                if not user_name:
                    user_name = self._get_lp_user_name(launchpad_id)
                user = self._create_user(launchpad_id, email, user_name)

            utils.store_user(self.runtime_storage_inst, user)

        return user
开发者ID:andersonvom,项目名称:stackalytics,代码行数:29,代码来源:record_processor.py


示例4: _update_members_company_name

def _update_members_company_name(runtime_storage_inst):
    LOG.debug('Update company names for members')
    record_processor_inst = record_processor.RecordProcessor(
        runtime_storage_inst)
    member_iterator = _get_changed_member_records(runtime_storage_inst,
                                                  record_processor_inst)

    for record in member_iterator:
        company_name = record['company_name']
        user = utils.load_user(runtime_storage_inst, record['user_id'])

        user['companies'] = [{
            'company_name': company_name,
            'end_date': 0,
        }]
        user['company_name'] = company_name

        utils.store_user(runtime_storage_inst, user)

        LOG.debug('Company name changed for user %s', user)

        record_id = record['record_id']
        runtime_storage_inst.memcached.set(
            runtime_storage_inst._get_record_name(record_id), record)
        runtime_storage_inst._commit_update(record_id)
开发者ID:knewstadt,项目名称:stackalytics,代码行数:25,代码来源:default_data_processor.py


示例5: _process_member

    def _process_member(self, record):
        user_id = "member:" + record['member_id']
        record['primary_key'] = user_id
        record['date'] = utils.member_date_to_timestamp(record['date_joined'])
        record['author_name'] = record['member_name']
        record['module'] = 'unknown'
        company_draft = record['company_draft']

        company_name = self.domains_index.get(utils.normalize_company_name(
            company_draft)) or (utils.normalize_company_draft(company_draft))

        # author_email is a key to create new user
        record['author_email'] = user_id
        record['company_name'] = company_name
        # _update_record_and_user function will create new user if needed
        self._update_record_and_user(record)
        record['company_name'] = company_name
        user = utils.load_user(self.runtime_storage_inst, user_id)

        user['user_name'] = record['author_name']
        user['companies'] = [{
            'company_name': company_name,
            'end_date': 0,
        }]
        user['company_name'] = company_name

        utils.store_user(self.runtime_storage_inst, user)

        record['company_name'] = company_name

        yield record
开发者ID:blueboxjesse,项目名称:stackalytics,代码行数:31,代码来源:record_processor.py


示例6: update_user

    def update_user(self, record):
        email = record.get('author_email')

        if email in self.users_index:
            user = self.users_index[email]
        else:
            if record.get('launchpad_id'):
                launchpad_id = record.get('launchpad_id')
                user_name = record.get('author_name')
            else:
                launchpad_id, user_name = self._get_lp_info(email)

            if (launchpad_id) and (launchpad_id in self.users_index):
                # merge emails
                user = self.users_index[launchpad_id]
                if email:
                    self._update_user_profile(user, email)
            else:
                # create new
                if not user_name:
                    user_name = record.get('author_name')
                if not user_name:
                    user_name = self._get_lp_user_name(launchpad_id)
                user = self._create_user(launchpad_id, email, user_name)

            utils.store_user(self.runtime_storage_inst, user)
            if email:
                self.users_index[email] = user
            if user['launchpad_id']:
                self.users_index[user['launchpad_id']] = user

        return user
开发者ID:cody-somerville,项目名称:stackalytics,代码行数:32,代码来源:record_processor.py


示例7: _store_users

def _store_users(runtime_storage_inst, users):
    for user in users:
        stored_user = utils.load_user(runtime_storage_inst, user['user_id'])
        if stored_user:
            stored_user.update(user)
            user = stored_user
        utils.store_user(runtime_storage_inst, user)
开发者ID:knewstadt,项目名称:stackalytics,代码行数:7,代码来源:default_data_processor.py


示例8: _process_member

    def _process_member(self, record):
        user_id = "member:" + record["member_id"]
        record["primary_key"] = user_id
        record["date"] = utils.member_date_to_timestamp(record["date_joined"])
        record["author_name"] = record["member_name"]
        record["module"] = "unknown"
        company_draft = record["company_draft"]

        company_name = self.domains_index.get(company_draft) or company_draft

        # author_email is a key to create new user
        record["author_email"] = user_id
        record["company_name"] = company_name
        # _update_record_and_user function will create new user if needed
        self._update_record_and_user(record)
        record["company_name"] = company_name
        user = utils.load_user(self.runtime_storage_inst, user_id)

        user["user_name"] = record["author_name"]
        user["companies"] = [{"company_name": company_name, "end_date": 0}]
        user["company_name"] = company_name

        utils.store_user(self.runtime_storage_inst, user)

        record["company_name"] = company_name

        yield record
开发者ID:jamesyli,项目名称:stackalytics,代码行数:27,代码来源:record_processor.py


示例9: _process_users

def _process_users(runtime_storage_inst, users):
    users_index = {}
    for user in users:
        utils.store_user(runtime_storage_inst, user)
        if 'user_id' in user:
            users_index[user['user_id']] = user
        if 'launchpad_id' in user:
            users_index[user['launchpad_id']] = user
        for email in user['emails']:
            users_index[email] = user
    runtime_storage_inst.set_by_key('users', users_index)
开发者ID:cp16net,项目名称:stackalytics,代码行数:11,代码来源:default_data_processor.py


示例10: _update_record_and_user

    def _update_record_and_user(self, record):
        email = record['author_email'].lower()
        record['author_email'] = email

        if email in self.users_index:
            user = self.users_index[email]
            record['launchpad_id'] = user['launchpad_id']
        else:
            if ('launchpad_id' in record) and (record['launchpad_id']):
                launchpad_id = record['launchpad_id']
                user_name = record['author_name']
            else:
                launchpad_id, user_name = self._get_lp_info(email)
                record['launchpad_id'] = launchpad_id

            if (launchpad_id) and (launchpad_id in self.users_index):
                # merge emails
                user = self.users_index[launchpad_id]
                self._update_user(user, email)
            else:
                # create new
                if not user_name:
                    user_name = record['author_name']
                user = self._create_user(launchpad_id, email, user_name)

            utils.store_user(self.runtime_storage_inst, user)
            self.users_index[email] = user
            if user['launchpad_id']:
                self.users_index[user['launchpad_id']] = user

        record['user_id'] = user['user_id']

        company_by_user = self._find_company(user['companies'], record['date'])
        if company_by_user == '*robots':
            # don't map robots by email
            company = company_by_user
        else:
            company = self._get_company_by_email(email)
            if not company:
                company = company_by_user
        record['company_name'] = company

        if ('user_name' in user) and (user['user_name']):
            record['author_name'] = user['user_name']
开发者ID:JohnGarbutt,项目名称:stackalytics,代码行数:44,代码来源:record_processor.py


示例11: _determine_core_contributors

    def _determine_core_contributors(self):
        LOG.debug("Determine core contributors")

        core_engineers = {}
        quarter_ago = int(time.time()) - 60 * 60 * 24 * 30 * 3  # a quarter ago

        for record in self.runtime_storage_inst.get_all_records():
            if record["record_type"] == "mark" and record["date"] > quarter_ago and record["value"] in [2, -2]:
                module_branch = (record["module"], record["branch"])
                user_id = record["user_id"]
                if user_id in core_engineers:
                    core_engineers[user_id].add(module_branch)
                else:
                    core_engineers[user_id] = set([module_branch])
        for user in self.runtime_storage_inst.get_all_users():
            core_old = user.get("core")
            user["core"] = list(core_engineers.get(user["user_id"], []))
            if user["core"] != core_old:
                utils.store_user(self.runtime_storage_inst, user)
开发者ID:jamesyli,项目名称:stackalytics,代码行数:19,代码来源:record_processor.py


示例12: _update_members_company_name

def _update_members_company_name(runtime_storage_inst):
    LOG.debug("Update company names for members")
    record_processor_inst = record_processor.RecordProcessor(runtime_storage_inst)
    member_iterator = _get_changed_member_records(runtime_storage_inst, record_processor_inst)

    for record in member_iterator:
        company_name = record["company_name"]
        user = utils.load_user(runtime_storage_inst, record["user_id"])

        user["companies"] = [{"company_name": company_name, "end_date": 0}]
        user["company_name"] = company_name

        utils.store_user(runtime_storage_inst, user)

        LOG.debug("Company name changed for user %s", user)

        record_id = record["record_id"]
        runtime_storage_inst.memcached.set(runtime_storage_inst._get_record_name(record_id), record)
        runtime_storage_inst._commit_update(record_id)
开发者ID:vnaboychenko,项目名称:stackalytics,代码行数:19,代码来源:default_data_processor.py


示例13: _determine_core_contributors

    def _determine_core_contributors(self):
        LOG.debug('Determine core contributors')

        core_engineers = {}
        quarter_ago = int(time.time()) - 60 * 60 * 24 * 30 * 3  # a quarter ago

        for record in self.runtime_storage_inst.get_all_records():
            if (record['record_type'] == 'mark' and
                    record['date'] > quarter_ago and
                    record['value'] in [2, -2]):
                module_branch = (record['module'], record['branch'])
                user_id = record['user_id']
                if user_id in core_engineers:
                    core_engineers[user_id].add(module_branch)
                else:
                    core_engineers[user_id] = set([module_branch])
        for user in self.runtime_storage_inst.get_all_users():
            core_old = user.get('core')
            user['core'] = list(core_engineers.get(user['user_id'], []))
            if user['core'] != core_old:
                utils.store_user(self.runtime_storage_inst, user)
开发者ID:zasimov,项目名称:stackalytics,代码行数:21,代码来源:record_processor.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python utils.timestamp_to_week函数代码示例发布时间:2022-05-27
下一篇:
Python utils.read_json_from_uri函数代码示例发布时间: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