avoid precaching users if not worthwhile
If the user specifies individual projects and doesn't need to map email addresses back to users, caching user <-> BZ email addresses is too much of an overhead. fixes: #22 Signed-off-by: Nils Philippsen <nils@redhat.com>
This commit is contained in:
parent
96eb19bcb7
commit
82374d6739
1 changed files with 17 additions and 7 deletions
|
@ -112,7 +112,8 @@ def segment(iterable, chunk, fill=None):
|
||||||
|
|
||||||
class BugzillaProxy:
|
class BugzillaProxy:
|
||||||
|
|
||||||
def __init__(self, bz_server, username, password, config):
|
def __init__(self, bz_server, username, password, config,
|
||||||
|
pre_cache_users=True):
|
||||||
self.bz_xmlrpc_server = bz_server
|
self.bz_xmlrpc_server = bz_server
|
||||||
self.username = username
|
self.username = username
|
||||||
self.password = password
|
self.password = password
|
||||||
|
@ -123,6 +124,7 @@ class BugzillaProxy:
|
||||||
password=self.password)
|
password=self.password)
|
||||||
|
|
||||||
self.product_cache = {}
|
self.product_cache = {}
|
||||||
|
self.user_cache = {}
|
||||||
self.inverted_user_cache = {}
|
self.inverted_user_cache = {}
|
||||||
|
|
||||||
# Connect to the fedora account system
|
# Connect to the fedora account system
|
||||||
|
@ -133,6 +135,12 @@ class BugzillaProxy:
|
||||||
|
|
||||||
self.config = config
|
self.config = config
|
||||||
|
|
||||||
|
if not pre_cache_users:
|
||||||
|
return
|
||||||
|
|
||||||
|
if config['verbose']:
|
||||||
|
print("Pre-caching FAS users and their Bugzilla email addresses.")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.user_cache = self.fas.people_by_key(
|
self.user_cache = self.fas.people_by_key(
|
||||||
key='username',
|
key='username',
|
||||||
|
@ -140,7 +148,7 @@ class BugzillaProxy:
|
||||||
except fedora.client.ServerError:
|
except fedora.client.ServerError:
|
||||||
# Sometimes, building the user cache up front fails with a timeout.
|
# Sometimes, building the user cache up front fails with a timeout.
|
||||||
# It's ok, we build the cache as-needed later in the script.
|
# It's ok, we build the cache as-needed later in the script.
|
||||||
self.user_cache = {}
|
pass
|
||||||
else:
|
else:
|
||||||
self.invert_user_cache()
|
self.invert_user_cache()
|
||||||
|
|
||||||
|
@ -743,13 +751,15 @@ class DistgitBugzillaSync:
|
||||||
times["data structure end"] = time.time()
|
times["data structure end"] = time.time()
|
||||||
delta = times["data structure end"] - times["start"]
|
delta = times["data structure end"] - times["start"]
|
||||||
print("Ran for %s seconds -- ie: %.2f minutes" % (delta, delta/60.0))
|
print("Ran for %s seconds -- ie: %.2f minutes" % (delta, delta/60.0))
|
||||||
print("Building FAS' cache")
|
|
||||||
|
|
||||||
# Initialize the connection to bugzilla
|
# Initialize the connection to bugzilla
|
||||||
bugzilla = BugzillaProxy(self.env['bugzilla']['url'],
|
bugzilla = BugzillaProxy(
|
||||||
self.env['bugzilla']['user'],
|
bz_server=self.env['bugzilla']['url'],
|
||||||
self.env['bugzilla']['password'],
|
username=self.env['bugzilla']['user'],
|
||||||
self.env)
|
password=self.env['bugzilla']['password'],
|
||||||
|
config=self.env,
|
||||||
|
pre_cache_users=not self.args.projects or self.args.print_fas_names,
|
||||||
|
)
|
||||||
|
|
||||||
if self.env["verbose"]:
|
if self.env["verbose"]:
|
||||||
times["FAS cache building end"] = time.time()
|
times["FAS cache building end"] = time.time()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue