|
| 1 | +import requests |
| 2 | +import json |
| 3 | + |
| 4 | +print("Getting NFR Reactions") |
| 5 | + |
| 6 | +comments = 'https://api.github.com/repos/phalcon/cphalcon/issues/14608/comments?page=' |
| 7 | +result = {} |
| 8 | +for i in range(1, 10): |
| 9 | + url = f"{comments}{i}" |
| 10 | + headers = { |
| 11 | + 'Accept': 'application/vnd.github.squirrel-girl-preview+json', |
| 12 | + 'User-Agent': 'Phalcon Agent' |
| 13 | + } |
| 14 | + |
| 15 | + response = requests.get(url, headers=headers) |
| 16 | + content = response.text |
| 17 | + |
| 18 | + print(f"Got content {i}") |
| 19 | + data = json.loads(content) |
| 20 | + |
| 21 | + for comment in data: |
| 22 | + id = comment.get('id', '') |
| 23 | + url = comment.get('html_url', '') |
| 24 | + body = comment.get('body', '') |
| 25 | + reactions = comment.get('reactions', {}) |
| 26 | + plusone = reactions.get('+1', 0) |
| 27 | + |
| 28 | + body = body.split('\n')[0].replace('\r', '').replace('\r\n', '') |
| 29 | + plusone = f"{int(plusone):03}" |
| 30 | + result[f"{plusone}-{id}"] = { |
| 31 | + 'reaction': plusone, |
| 32 | + 'body': f"[{body}]({url})" |
| 33 | + } |
| 34 | + |
| 35 | +print("Sorting Results") |
| 36 | +sorted_result = dict(sorted(result.items(), key=lambda item: item[0], reverse=True)) |
| 37 | + |
| 38 | +print("Creating Content") |
| 39 | +output = "# New Feature Request List\n" |
| 40 | +output += "- - -\n\n" |
| 41 | +output += "| Votes | Description |\n" |
| 42 | +output += "|--------|-------------------------|\n" |
| 43 | +for item in sorted_result.values(): |
| 44 | + output += f"| {item['reaction']} | {item['body']} |\n" |
| 45 | + |
| 46 | +output += "\n" |
| 47 | + |
| 48 | +file_name = 'docs/new-feature-request-list.md' |
| 49 | +with open(file_name, 'w') as file: |
| 50 | + file.write(output) |
0 commit comments