File tree Expand file tree Collapse file tree 2 files changed +75
-0
lines changed Expand file tree Collapse file tree 2 files changed +75
-0
lines changed Original file line number Diff line number Diff line change
1
+ name : Issues Summary
2
+
3
+ on :
4
+ schedule :
5
+ - cron : ' 0 0 * * 2' # Runs every Tuesday at midnight
6
+ workflow_dispatch :
7
+
8
+ jobs :
9
+ generate-summary :
10
+ runs-on : ubuntu-latest
11
+
12
+ steps :
13
+ - name : Checkout repository
14
+ uses : actions/checkout@v2
15
+
16
+ - name : Set up Python
17
+ uses : actions/setup-python@v2
18
+ with :
19
+ python-version : ' 3.x'
20
+
21
+ - name : Install dependencies
22
+ run : |
23
+ python -m pip install --upgrade pip
24
+ pip install requests
25
+
26
+ - name : Run summary script
27
+ run : python scripts/generate_summary.py
28
+ env :
29
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
Original file line number Diff line number Diff line change
1
+ import requests
2
+ import os
3
+ from datetime import datetime , timezone
4
+
5
+ GITHUB_API_URL = "https://api.github.com"
6
+ REPO = "microsoft/vscode-python"
7
+ TOKEN = os .getenv ("GITHUB_TOKEN" )
8
+
9
+
10
+ def fetch_issues ():
11
+ headers = {"Authorization" : f"token { TOKEN } " }
12
+ query = f"{ GITHUB_API_URL } /repos/{ REPO } /issues?state=open&per_page=100"
13
+ response = requests .get (query , headers = headers )
14
+ response .raise_for_status ()
15
+ return response .json ()
16
+
17
+
18
+ def calculate_thumbs_up_per_day (issue ):
19
+ created_at = datetime .strptime (issue ["created_at" ], "%Y-%m-%dT%H:%M:%SZ" )
20
+ now = datetime .now (timezone .utc )
21
+ days_open = (now - created_at ).days or 1
22
+ thumbs_up = next (
23
+ (group ["count" ] for group in issue ["reactions" ] if group ["content" ] == "+1" ), 0
24
+ )
25
+ return thumbs_up / days_open
26
+
27
+
28
+ def generate_markdown_summary (issues ):
29
+ summary = "| URL | Title | 👍/day |\n | --- | ----- | ------ |\n "
30
+ for issue in issues :
31
+ thumbs_up_per_day = calculate_thumbs_up_per_day (issue )
32
+ summary += (
33
+ f"| { issue ['html_url' ]} | { issue ['title' ]} | { thumbs_up_per_day :.2f} |\n "
34
+ )
35
+ return summary
36
+
37
+
38
+ def main ():
39
+ issues = fetch_issues ()
40
+ summary = generate_markdown_summary (issues )
41
+ with open ("endorsement_velocity_summary.md" , "w" ) as f :
42
+ f .write (summary )
43
+
44
+
45
+ if __name__ == "__main__" :
46
+ main ()
You can’t perform that action at this time.
0 commit comments