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)
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)
Beispiel #3
0
    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['country'] = record.get("country")
        record['email'] = record.get("email")
        record['module'] = 'unknown'
        company_draft = record['company_draft']

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

        # author_email is a key to create new user
        record['author_email'] = record["email"] or 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,
                               record['user_id'] or 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
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)
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)
Beispiel #6
0
    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)
Beispiel #7
0
    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')

        ldap_id = record.get('ldap_id')
        user_l = utils.load_user(self.runtime_storage_inst, ldap_id) or {}

        user = self._create_user(ldap_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
                LOG.debug('Created new user: %s', user)

            utils.store_user(self.runtime_storage_inst, user)

        return user