implemented timecheck for gsql
This commit is contained in:
parent
acdf656552
commit
a0e533f249
@ -5,12 +5,14 @@ import os
|
||||
|
||||
key = os.environ.get('KKEXKEY')
|
||||
|
||||
def main(vcs):
|
||||
def main(vcs, early_cutoff):
|
||||
gsql_dict = {}
|
||||
vcs_list = vcs[0].split('/')
|
||||
repo_name = '"' + vcs_list[-1] + '"'
|
||||
repo_owner = '"' + vcs_list[-2] + '"'
|
||||
returned_content = get_discussion_gql(repo_owner, repo_name)
|
||||
return returned_content
|
||||
gsql_dict["original_returned_content"] = get_discussion_gql(repo_owner, repo_name)
|
||||
gsql_dict["time_cleaned_comm"] = within_time(gsql_dict["original_returned_content"].content, early_cutoff)
|
||||
return gsql_dict
|
||||
|
||||
def get_discussion_gql(repo_owner, repo_name):
|
||||
url = "https://api.github.com/graphql"
|
||||
@ -61,6 +63,16 @@ def get_discussion_gql(repo_owner, repo_name):
|
||||
print(r.content)
|
||||
return r
|
||||
|
||||
def within_time(comment_content, early_cutoff):
|
||||
list_of_comments = json.loads(comment_content)["data"]["repository"]["discussions"]["edges"]
|
||||
valid_comments = []
|
||||
for comment in list_of_comments:
|
||||
if dt.datetime.fromisoformat(comment['node']['createdAt'][:-1]) < early_cutoff:
|
||||
break
|
||||
else:
|
||||
valid_comments.append(comment)
|
||||
return valid_comments
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
get_discussion_gql()
|
||||
|
7
main.py
7
main.py
@ -9,7 +9,7 @@ import gh_gsql_req as ghs
|
||||
|
||||
def main():
|
||||
# we should discuss whether we're using the 93 day window that seems to be widely used or if we want a longer window
|
||||
early_cutoff = dt.datetime(2023,6, 17)
|
||||
early_cutoff = dt.datetime(2023,10, 11)
|
||||
print("Earliest date examined: " + str(early_cutoff))
|
||||
#placeholder for now
|
||||
manifest = '../kaylea_dissertation/lifecycle/package_metadata/jupyter-notebook_manifest.yaml'
|
||||
@ -35,9 +35,8 @@ def main():
|
||||
new_formality = compute_formality_score(new_mmt, gha_obj['milestone_count'], perceval_obj['age_of_project'])
|
||||
print(new_formality)
|
||||
# testing out beneath:
|
||||
# TODO: incorporate early cutoff to this, probably in a cleaning function
|
||||
ghs_obj = ghs.main(vcs_path)
|
||||
print(ghs_obj)
|
||||
ghs_obj = ghs.main(vcs_path, early_cutoff)
|
||||
print(ghs_obj["time_cleaned_comm"])
|
||||
except yaml.YAMLOError as err:
|
||||
print(err)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user