Skip to content

Commit

Permalink
progress report
Browse files Browse the repository at this point in the history
  • Loading branch information
brownsarahm committed Oct 15, 2023
1 parent 73e9f86 commit 2323b28
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 2 deletions.
60 changes: 60 additions & 0 deletions badges.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import click
from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PublicKey
from cryptography.exceptions import InvalidSignature
from .config import gh_approvers
import json


badge_types = ['review', 'practice', 'explore', 'experience',
'build', 'lab','community']


@click.command()
@click.option('-b','--badge-name',help="name of the badge formated like type.YYYY-MM-DD")
@click.option('-a','--approver',help='github username of the badge issuer')
Expand Down Expand Up @@ -94,6 +100,60 @@ def process_badges(json_output,file_out = None):
# author = review_df['author'].apply(pd.Series)



@click.command()
@click.option('-j','--json-output',default='badges.json',type=click.File('r'),
help='json file to parse')
@click.option('-f','--file-out',default=None,type=click.File('w'),
help='to write to a file, otherwise will echo')

def get_approved_titles(json_output,file_out = None):
'''
process gh cli json
Parameters
----------
json_output : filename
file generated from `gh pr list -s all --json title,latestReviews `
file_out : file name
file to be generated and store the output
'''

with open(json_output, 'r') as f:
PR_list = json.load(f)

#filter for ones with reviews
reviewed = [(pr['title'], pr['latestReviews'][0])
for pr in PR_list if pr['latestReviews']]
# filter to only process approved ones latestReviews.state
# extract title, latestReviews.author.login, latestReviews.body,
logged_badges = [title for title,review in reviewed
if review['state'] == 'APPROVED' and
review['author']['login']in gh_approvers]

out_list = '\n'.join(logged_badges)

if file_out:
titles_by_type = {bt:[t for t in logged_badges if type in t.lower()]
for bt in badge_types}
verified_by_type = '\n'.join(['## '+bt + ' ('+str(len(bl)) +')' +'\n - '+'\n - '. join(bl)
for bt,bl in titles_by_type.items()])
valid_badges = [vi for v in titles_by_type.values() for vi in v]
not_typed = [p for p in logged_badges if not(p in valid_badges)]
with open(file_out,'w') as f:
f.write('## all approved ')
f.write(out_list)
f.write(verified_by_type)
f.write('## Cannot match as a typed badge')
f.write('\n- ' + '\n - '.join(not_typed))
else:
click.echo(out_list)

block_template = '''
# {type}
'''


#
# Put this in student repos
# on:
Expand Down
6 changes: 4 additions & 2 deletions config.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@

repo = 'http://introcompsys.github.io/fall2022/'
base_url = 'https://raw.githubusercontent.com/introcompsys/fall2022/main/_'
repo = 'http://introcompsys.github.io/fall2023/'
base_url = 'https://raw.githubusercontent.com/introcompsys/fall2023/main/_'

gh_approvers = ['brownsarahm','ascott20','marcinpawlukiewicz']
9 changes: 9 additions & 0 deletions tasktracking.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,15 @@ def get_assignment(date, assignment_type = 'prepare'):
# help='date should be YYYY-MM-DD of the tasks you want and must be valid')

def fetch_to_checklist(date, assignment_type = 'prepare'):
'''
get assignment text and change numbered items to a checklist
Parameters
----------
date : string
YYYY-MM-DD formatted strings of the date to get
assignment_type :
'''


path = base_url +assignment_type + '/' + date +'.md'
Expand Down

0 comments on commit 2323b28

Please sign in to comment.