Get all issues closed since a particular point in time. *period* can either be a datetime object, or a timedelta object. In the latter case, it is used as a time before the present.
(period=timedelta(days=365),
project='matplotlib/matplotlib', pulls=False)
| 103 | |
| 104 | |
| 105 | def issues_closed_since(period=timedelta(days=365), |
| 106 | project='matplotlib/matplotlib', pulls=False): |
| 107 | """ |
| 108 | Get all issues closed since a particular point in time. |
| 109 | |
| 110 | *period* can either be a datetime object, or a timedelta object. In the |
| 111 | latter case, it is used as a time before the present. |
| 112 | """ |
| 113 | |
| 114 | which = 'pulls' if pulls else 'issues' |
| 115 | |
| 116 | if isinstance(period, timedelta): |
| 117 | since = round_hour(datetime.utcnow() - period) |
| 118 | else: |
| 119 | since = period |
| 120 | url = ( |
| 121 | f'https://api.github.com/repos/{project}/{which}' |
| 122 | f'?state=closed' |
| 123 | f'&sort=updated' |
| 124 | f'&since={since.strftime(ISO8601)}' |
| 125 | f'&per_page={PER_PAGE}') |
| 126 | allclosed = get_paged_request(url, headers=make_auth_header()) |
| 127 | |
| 128 | filtered = (i for i in allclosed |
| 129 | if _parse_datetime(i['closed_at']) > since) |
| 130 | if pulls: |
| 131 | filtered = (i for i in filtered |
| 132 | if _parse_datetime(i['merged_at']) > since) |
| 133 | # filter out PRs not against main (backports) |
| 134 | filtered = (i for i in filtered if i['base']['ref'] == 'main') |
| 135 | else: |
| 136 | filtered = (i for i in filtered if not is_pull_request(i)) |
| 137 | |
| 138 | return list(filtered) |
| 139 | |
| 140 | |
| 141 | def sorted_by_field(issues, field='closed_at', reverse=False): |
no test coverage detected
searching dependent graphs…