| Total Complexity | 8 | 
| Total Lines | 33 | 
| Duplicated Lines | 0 % | 
| 1 | import datetime  | 
            ||
| 11 | class ListIssuesAction(BaseGithubAction):  | 
            ||
| 12 | def run(self, user, repo, filter=None, state=None, sort=None,  | 
            ||
| 13 | direction=None, since=None, limit=20):  | 
            ||
| 14 | user = self._client.get_user(user)  | 
            ||
| 15 | repo = user.get_repo(repo)  | 
            ||
| 16 | |||
| 17 |         kwargs = {} | 
            ||
| 18 | if filter:  | 
            ||
| 19 | kwargs['filter'] = filter  | 
            ||
| 20 | if state:  | 
            ||
| 21 | kwargs['state'] = state  | 
            ||
| 22 | if sort:  | 
            ||
| 23 | kwargs['sort'] = sort  | 
            ||
| 24 | if direction:  | 
            ||
| 25 | kwargs['direction'] = direction  | 
            ||
| 26 | if since:  | 
            ||
| 27 | kwargs['since'] = datetime.datetime.fromtimestamp(since)  | 
            ||
| 28 | |||
| 29 | # Note: PyGithub library introduces an abstraction for paginated lists  | 
            ||
| 30 | # which doesn't conform to Python's iterator spec so we can't use  | 
            ||
| 31 | # array slicing to exhaust the list :/  | 
            ||
| 32 | issues = repo.get_issues(**kwargs)  | 
            ||
| 33 | issues = list(issues)  | 
            ||
| 34 | |||
| 35 | result = []  | 
            ||
| 36 | for index, issue in enumerate(issues):  | 
            ||
| 37 | issue = issue_to_dict(issue=issue)  | 
            ||
| 38 | result.append(issue)  | 
            ||
| 39 | |||
| 40 | if (index + 1) >= limit:  | 
            ||
| 41 | break  | 
            ||
| 42 | |||
| 43 | return result  | 
            ||
| 44 |