Skip to content

Commit

Permalink
Support passing issue_limit in the config
Browse files Browse the repository at this point in the history
  • Loading branch information
kostajh committed Dec 6, 2016
1 parent 12759f2 commit efec9fc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
6 changes: 3 additions & 3 deletions bugwarrior/docs/services/redmine.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ Here's an example of a Redmine target::
redmine.key = c0c4c014cafebabe
redmine.user_id = 7
redmine.project_name = redmine
redmine.issue_limit = 1000

The above example is the minimum required to import issues from
Redmine. You can also feel free to use any of the
configuration options described in :ref:`common_configuration_options`.
You can also feel free to use any of the configuration options described in
:ref:`common_configuration_options`.

There are also `redmine.login`/`redmine.password` settings if your
instance is behind basic auth.
Expand Down
14 changes: 9 additions & 5 deletions bugwarrior/services/redmine.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,18 @@


class RedMineClient(ServiceClient):
def __init__(self, url, key, auth):
def __init__(self, url, key, auth, issue_limit):
self.url = url
self.key = key
self.auth = auth
self.issue_limit = issue_limit

def find_issues(self, user_id=None):
args = {"limit": 100}
def find_issues(self, user_id=None, issue_limit=25):
args = {}
if user_id is not None:
args["assigned_to_id"] = user_id
if issue_limit is not None:
args["limit"] = issue_limit
return self.call_api("/issues.json", args)["issues"]

def call_api(self, uri, params):
Expand Down Expand Up @@ -106,12 +109,13 @@ def __init__(self, *args, **kw):
self.url = self.config_get('url').rstrip("/")
self.key = self.config_get('key')
self.user_id = self.config_get('user_id')
self.issue_limit = self.config_get('issue_limit')

login = self.config_get_default('login')
if login:
password = self.config_get_password('password', login)
auth = (login, password) if (login and password) else None
self.client = RedMineClient(self.url, self.key, auth)
self.client = RedMineClient(self.url, self.key, auth, self.issue_limit)

self.project_name = self.config_get_default('project_name')

Expand All @@ -137,7 +141,7 @@ def validate_config(cls, config, target):
IssueService.validate_config(config, target)

def issues(self):
issues = self.client.find_issues(self.user_id)
issues = self.client.find_issues(self.user_id, self.issue_limit)
log.debug(" Found %i total.", len(issues))

for issue in issues:
Expand Down

0 comments on commit efec9fc

Please sign in to comment.