feat: attribute multiple issues addressed in a single PR in awards.csv (#2153)
This commit is contained in:
parent
f01a5fde00
commit
faf11138c4
2
.github/workflows/extend-awards.yml
vendored
2
.github/workflows/extend-awards.yml
vendored
@ -53,5 +53,5 @@ jobs:
|
||||
branch: extend-awards/patch
|
||||
commit-message: Extending awards.csv
|
||||
title: Extending awards.csv
|
||||
body: One or more PR's were merged that solve an issue(s) and awards.csv should be extended. Remembere to delete the branch after merging.
|
||||
body: One or more PR's were merged that solve an issue(s) and awards.csv should be extended. Remember to delete the branch after merging.
|
||||
delete-branch: true
|
||||
|
@ -15,15 +15,17 @@ def getIssue(n):
|
||||
j = json.loads(r.text)
|
||||
return j
|
||||
|
||||
def findIssueInPR(j):
|
||||
def findIssuesInPR(j):
|
||||
p = re.compile('(#|https://github.com/stackernews/stacker.news/issues/)([0-9]+)')
|
||||
issues = set()
|
||||
for m in p.finditer(j['title']):
|
||||
return m.group(2)
|
||||
issues.add(m.group(2))
|
||||
if not 'body' in j or j['body'] is None:
|
||||
return
|
||||
for s in j['body'].split('\n'):
|
||||
for m in p.finditer(s):
|
||||
return m.group(2)
|
||||
issues.add(m.group(2))
|
||||
return list(issues)
|
||||
|
||||
def addAward(user, kind, pr, issue, difficulty, priority, count, amount):
|
||||
if amount >= 1000000 and amount % 1000000 == 0:
|
||||
@ -59,10 +61,11 @@ def countReviews(pr):
|
||||
def checkPR(i):
|
||||
pr = str(i['number'])
|
||||
print('pr %s' % pr)
|
||||
n = findIssueInPR(i)
|
||||
if not n:
|
||||
print('pr %s does not solve an issue' % pr)
|
||||
issue_numbers = findIssuesInPR(i)
|
||||
if not issue_numbers:
|
||||
print('pr %s does not solve any issues' % pr)
|
||||
return
|
||||
for n in issue_numbers:
|
||||
print('solves issue %s' % n)
|
||||
j = getIssue(n)
|
||||
difficulty = ''
|
||||
@ -80,11 +83,11 @@ def checkPR(i):
|
||||
multiplier = priorities[p]
|
||||
if amount * multiplier <= 0:
|
||||
print('issue gives no award')
|
||||
return
|
||||
continue
|
||||
count = countReviews(pr)
|
||||
if count >= 10:
|
||||
print('too many reviews, no award')
|
||||
return
|
||||
continue
|
||||
if count > 0:
|
||||
print('%d reviews, %d%% reduction' % (count, count * 10))
|
||||
award = amount * multiplier * (10 - count) / 10
|
||||
|
Loading…
x
Reference in New Issue
Block a user