1010
1111zulip_token = sys .argv [1 ]
1212gh_token = sys .argv [2 ]
13+ should_send_to_zulip = sys .argv [3 ]
1314
1415zulip_client = zulip .
Client (
email = "[email protected] " ,
api_key = zulip_token ,
site = "https://leanprover.zulipchat.com" )
1516
@@ -30,25 +31,35 @@ def message_date(id):
3031gh = github .Github (login_or_token = gh_token )
3132mathlib = gh .get_repo ('leanprover-community/mathlib4' )
3233
33- open_items = mathlib .get_issues (state = 'open' )
34- open_prs = []
34+ now = datetime .datetime .now (tz = datetime .timezone .utc )
35+ delta = datetime .timedelta (days = 7 )
36+ min_age = now - delta
37+
38+ open_issues_raw = mathlib .get_issues (state = 'open' )
3539open_issues = []
40+ open_prs_raw = mathlib .get_pulls (state = 'open' )
41+ open_prs = []
3642
37- print (f'Found { open_items .totalCount } open item (s) (PRs and issues ).' )
43+ print (f'Found { open_prs_raw .totalCount } open PR (s) and { open_issues_raw . totalCount } open issue(s ).' )
3844
39- for i in open_items :
40- now = datetime .datetime .now (tz = datetime .timezone .utc )
41- delta = datetime .timedelta (days = 7 )
42- min_age = now - delta
43- if i .updated_at < min_age \
44- and 'blocked-by-other-PR' not in [l .name for l in i .labels ] \
45- and not (i .number in posted_topics and datetime .datetime .fromtimestamp (posted_topics [i .number ], tz = datetime .timezone .utc ) > min_age ):
46- if i .pull_request :
47- open_prs .append (i )
48- else :
49- open_issues .append (i )
45+ # Process issues (need to filter out PRs since get_issues returns both)
46+ for issue in open_issues_raw :
47+ if not issue .pull_request : # Only process actual issues
48+ if issue .updated_at < min_age \
49+ and 'blocked-by-other-PR' not in [l .name for l in issue .labels ] \
50+ and not (issue .number in posted_topics and datetime .datetime .fromtimestamp (posted_topics [issue .number ], tz = datetime .timezone .utc ) > min_age ):
51+ open_issues .append (issue )
5052
5153print (f'Found { len (open_issues )} open issue(s) after filtering.' )
54+
55+ # Process PRs
56+ for pr in open_prs_raw :
57+ if pr .updated_at < min_age \
58+ and 'blocked-by-other-PR' not in [l .name for l in pr .labels ] \
59+ and not (pr .number in posted_topics and datetime .datetime .fromtimestamp (posted_topics [pr .number ], tz = datetime .timezone .utc ) > min_age ) \
60+ and not pr .draft :
61+ open_prs .append (pr )
62+
5263print (f'Found { len (open_prs )} open PR(s) after filtering.' )
5364
5465def post_random (select_from , kind ):
@@ -76,7 +87,8 @@ def post_random(select_from, kind):
7687
7788 print (content )
7889
79- zulip_client .send_message (post )
90+ if should_send_to_zulip != "false" :
91+ zulip_client .send_message (post )
8092
8193post_random (open_issues , 'issue' )
8294post_random (open_prs , 'PR' )
0 commit comments