8000 Add a class to handle a list of Bugs by ThomasFaivre · Pull Request #24 · rawrgulmuffins/bugzillatools · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add a class to handle a list of Bugs #24

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: 0.6.0.dev
Choose a base branch
from

Conversation

ThomasFaivre
Copy link

Hello!

I noticed something while automating some stuff with Bugzilla, if we want to get or update data from several bugs, it can take quite some time. This comes from the fact that for each bug, a RPC request is sent although the RPC API allows the use of a list of bugs id for some method (mainly get and update).

So I have written a class that can use this feature. This class inherits from a list (functional append, extend, insert, ...), gets data from server lazily and is much much faster when handling a large number of bugs:

import timeit
>>> setup = """
... from bzlib.bugzilla import Bugzilla
... from bzlib.config import Config
... from bzlib.bug import Bug, Bugs
...
... bz = Bugzilla.from_config(Config.get_config("~/.bugzillarc"),
...                           server=None, url=None, user=None, password=None)
... """

# 10 Bugs
>>> timeit.timeit(stmt='Bugs(bz, *range(50000,50010)).data', setup=setup, number=1)
1.1943719387054443
>>> timeit.timeit(stmt='for num in range(50000, 50010): Bug(bz, num).data', setup=setup, number=1)
8.836580991744995

# 100 Bugs
>>> timeit.timeit(stmt='Bugs(bz, *range(50000,50100)).data', setup=setup, number=1)
1.8374311923980713
>>> timeit.timeit(stmt='for num in range(50000, 50100): Bug(bz, num).data', setup=setup, number=1)`
67.8080358505249`

It is only the base of the class, it is missing some method like the set_* of the Bug class but the main is here and the rest can be easily added.

I also added a small patch to make bugzilla, bug and config modules public when importing bzlib alone. They are the most used modules of the library (the rest is for the cli so not really public) so I thought it would be nice to have this.

Thanks!

Only add the bug, bugzilla and config modules as they are the most used.

Signed-off-by: Thomas Faivre <thomas.faivre@6wind.com>
The XML-RPC API for Bugzilla allows the use of several bug numbers for
some request such as 'get' and 'update'.
When dealing with a log of bugs, using this class will strongly improve
performance as less request will actually be sent and response received.

Only basic methods are implemented for now.

IMPORTANT NOTES: The API only allows to update all the given bugs with the
same value. This must stay in mind when using this new class.

Signed-off-by: Thomas Faivre <thomas.faivre@6wind.com>
@rawrgulmuffins
Copy link
Owner

Hello Thomas,

Brooks and I are sorry it's taken us so long to look at this PR. I'll be looking at it tonight.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0