Merge "Add fetching_user_source config option"
This commit is contained in:
commit
0457148b39
@ -3,6 +3,7 @@ usage: stackalytics-processor [-h] [--config-dir DIR] [--config-file PATH]
|
|||||||
[--days_to_update_members DAYS_TO_UPDATE_MEMBERS]
|
[--days_to_update_members DAYS_TO_UPDATE_MEMBERS]
|
||||||
[--debug] [--default-data-uri DEFAULT_DATA_URI]
|
[--debug] [--default-data-uri DEFAULT_DATA_URI]
|
||||||
[--driverlog-data-uri DRIVERLOG_DATA_URI]
|
[--driverlog-data-uri DRIVERLOG_DATA_URI]
|
||||||
|
[--fetching-user-source FETCHING_USER_SOURCE]
|
||||||
[--gerrit-retry GERRIT_RETRY]
|
[--gerrit-retry GERRIT_RETRY]
|
||||||
[--git-base-uri GIT_BASE_URI]
|
[--git-base-uri GIT_BASE_URI]
|
||||||
[--log-config-append PATH]
|
[--log-config-append PATH]
|
||||||
@ -44,6 +45,8 @@ optional arguments:
|
|||||||
file:///path/to/default_data.json
|
file:///path/to/default_data.json
|
||||||
--driverlog-data-uri DRIVERLOG_DATA_URI
|
--driverlog-data-uri DRIVERLOG_DATA_URI
|
||||||
URI for default data
|
URI for default data
|
||||||
|
--fetching-user-source FETCHING_USER_SOURCE
|
||||||
|
Source for fetching user profiles
|
||||||
--gerrit-retry GERRIT_RETRY
|
--gerrit-retry GERRIT_RETRY
|
||||||
How many times to retry after Gerrit errors
|
How many times to retry after Gerrit errors
|
||||||
--git-base-uri GIT_BASE_URI
|
--git-base-uri GIT_BASE_URI
|
||||||
|
@ -176,6 +176,10 @@
|
|||||||
# URI of translation team data (string value)
|
# URI of translation team data (string value)
|
||||||
#translation_team_uri = https://git.openstack.org/cgit/openstack/i18n/plain/tools/zanata/translation_team.yaml
|
#translation_team_uri = https://git.openstack.org/cgit/openstack/i18n/plain/tools/zanata/translation_team.yaml
|
||||||
|
|
||||||
|
# Source for fetching user profiles (string value)
|
||||||
|
# Allowed values: launchpad, <None>
|
||||||
|
#fetching_user_source = launchpad
|
||||||
|
|
||||||
# How many member profiles to look ahead after the last (integer value)
|
# How many member profiles to look ahead after the last (integer value)
|
||||||
#members_look_ahead = 250
|
#members_look_ahead = 250
|
||||||
|
|
||||||
|
@ -54,6 +54,9 @@ PROCESSOR_OPTS = [
|
|||||||
default='https://git.openstack.org/cgit/openstack/i18n/'
|
default='https://git.openstack.org/cgit/openstack/i18n/'
|
||||||
'plain/tools/zanata/translation_team.yaml',
|
'plain/tools/zanata/translation_team.yaml',
|
||||||
help='URI of translation team data'),
|
help='URI of translation team data'),
|
||||||
|
cfg.StrOpt("fetching-user-source", default='launchpad',
|
||||||
|
choices=['launchpad', '<None>'],
|
||||||
|
help="Source for fetching user profiles"),
|
||||||
cfg.IntOpt('members-look-ahead', default=250,
|
cfg.IntOpt('members-look-ahead', default=250,
|
||||||
help='How many member profiles to look ahead after the last'),
|
help='How many member profiles to look ahead after the last'),
|
||||||
cfg.IntOpt('read-timeout', default=120,
|
cfg.IntOpt('read-timeout', default=120,
|
||||||
|
@ -19,6 +19,7 @@ import copy
|
|||||||
import functools
|
import functools
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
from oslo_config import cfg
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
import six
|
import six
|
||||||
|
|
||||||
@ -27,6 +28,7 @@ from stackalytics.processor import user_processor
|
|||||||
from stackalytics.processor import utils
|
from stackalytics.processor import utils
|
||||||
|
|
||||||
|
|
||||||
|
CONF = cfg.CONF
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@ -232,6 +234,9 @@ class RecordProcessor(object):
|
|||||||
self.runtime_storage_inst, u)
|
self.runtime_storage_inst, u)
|
||||||
return merged_user
|
return merged_user
|
||||||
|
|
||||||
|
def _need_to_fetch_launchpad(self):
|
||||||
|
return CONF.fetching_user_source == 'launchpad'
|
||||||
|
|
||||||
def update_user(self, record):
|
def update_user(self, record):
|
||||||
email = record.get('author_email')
|
email = record.get('author_email')
|
||||||
user_e = user_processor.load_user(
|
user_e = user_processor.load_user(
|
||||||
@ -239,8 +244,8 @@ class RecordProcessor(object):
|
|||||||
|
|
||||||
user_name = record.get('author_name')
|
user_name = record.get('author_name')
|
||||||
launchpad_id = record.get('launchpad_id')
|
launchpad_id = record.get('launchpad_id')
|
||||||
if (email and (not user_e) and (not launchpad_id) and
|
if (self._need_to_fetch_launchpad() and email and (not user_e) and
|
||||||
(not user_e.get('launchpad_id'))):
|
(not launchpad_id) and (not user_e.get('launchpad_id'))):
|
||||||
# query LP
|
# query LP
|
||||||
launchpad_id, lp_user_name = self._get_lp_info(email)
|
launchpad_id, lp_user_name = self._get_lp_info(email)
|
||||||
if lp_user_name:
|
if lp_user_name:
|
||||||
@ -250,8 +255,8 @@ class RecordProcessor(object):
|
|||||||
if gerrit_id:
|
if gerrit_id:
|
||||||
user_g = user_processor.load_user(
|
user_g = user_processor.load_user(
|
||||||
self.runtime_storage_inst, gerrit_id=gerrit_id) or {}
|
self.runtime_storage_inst, gerrit_id=gerrit_id) or {}
|
||||||
if ((not user_g) and (not launchpad_id) and
|
if (self._need_to_fetch_launchpad() and (not user_g) and
|
||||||
(not user_e.get('launchpad_id'))):
|
(not launchpad_id) and (not user_e.get('launchpad_id'))):
|
||||||
# query LP
|
# query LP
|
||||||
guessed_lp_id = gerrit_id
|
guessed_lp_id = gerrit_id
|
||||||
lp_user_name = self._get_lp_user_name(guessed_lp_id)
|
lp_user_name = self._get_lp_user_name(guessed_lp_id)
|
||||||
@ -264,8 +269,8 @@ class RecordProcessor(object):
|
|||||||
if zanata_id:
|
if zanata_id:
|
||||||
user_z = user_processor.load_user(
|
user_z = user_processor.load_user(
|
||||||
self.runtime_storage_inst, zanata_id=zanata_id) or {}
|
self.runtime_storage_inst, zanata_id=zanata_id) or {}
|
||||||
if ((not user_z) and (not launchpad_id) and
|
if (self._need_to_fetch_launchpad() and (not user_z) and
|
||||||
(not user_e.get('launchpad_id'))):
|
(not launchpad_id) and (not user_e.get('launchpad_id'))):
|
||||||
# query LP
|
# query LP
|
||||||
guessed_lp_id = zanata_id
|
guessed_lp_id = zanata_id
|
||||||
user_name = self._get_lp_user_name(guessed_lp_id)
|
user_name = self._get_lp_user_name(guessed_lp_id)
|
||||||
@ -290,7 +295,7 @@ class RecordProcessor(object):
|
|||||||
[user_e, user_l, user_g, user_z, user])
|
[user_e, user_l, user_g, user_z, user])
|
||||||
else:
|
else:
|
||||||
# create new
|
# create new
|
||||||
if not user_name:
|
if (self._need_to_fetch_launchpad() and not user_name):
|
||||||
user_name = self._get_lp_user_name(launchpad_id)
|
user_name = self._get_lp_user_name(launchpad_id)
|
||||||
if user_name:
|
if user_name:
|
||||||
user['user_name'] = user_name
|
user['user_name'] = user_name
|
||||||
|
@ -16,15 +16,19 @@
|
|||||||
import time
|
import time
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
|
from oslo_config import cfg
|
||||||
import six
|
import six
|
||||||
import testtools
|
import testtools
|
||||||
|
|
||||||
|
from stackalytics.processor import config
|
||||||
from stackalytics.processor import record_processor
|
from stackalytics.processor import record_processor
|
||||||
from stackalytics.processor import runtime_storage
|
from stackalytics.processor import runtime_storage
|
||||||
from stackalytics.processor import user_processor
|
from stackalytics.processor import user_processor
|
||||||
from stackalytics.processor import utils
|
from stackalytics.processor import utils
|
||||||
|
|
||||||
|
|
||||||
|
CONF = cfg.CONF
|
||||||
|
|
||||||
RELEASES = [
|
RELEASES = [
|
||||||
{
|
{
|
||||||
'release_name': 'prehistory',
|
'release_name': 'prehistory',
|
||||||
@ -67,6 +71,7 @@ class TestRecordProcessor(testtools.TestCase):
|
|||||||
self.lp_profile_by_email = (
|
self.lp_profile_by_email = (
|
||||||
self.lp_profile_by_email_patch.start())
|
self.lp_profile_by_email_patch.start())
|
||||||
self.lp_profile_by_email.return_value = None
|
self.lp_profile_by_email.return_value = None
|
||||||
|
CONF.register_opts(config.CONNECTION_OPTS + config.PROCESSOR_OPTS)
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
super(TestRecordProcessor, self).tearDown()
|
super(TestRecordProcessor, self).tearDown()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user