fixing how to get discussion comments
This commit is contained in:
parent
28e34de14b
commit
41c79f0a73
123
gh_gsql_req.py
123
gh_gsql_req.py
@ -19,40 +19,39 @@ def get_discussion_gql(repo_owner, repo_name):
|
|||||||
data_string = ("""
|
data_string = ("""
|
||||||
query {
|
query {
|
||||||
repository(owner: """ + repo_owner + """, name: """ + repo_name + """) {
|
repository(owner: """ + repo_owner + """, name: """ + repo_name + """) {
|
||||||
discussions(first: 3) {
|
issues(last: 2) {
|
||||||
# type: DiscussionConnection
|
edges {
|
||||||
totalCount # Int!
|
node {
|
||||||
|
id
|
||||||
edges {
|
title
|
||||||
# type: DiscussionEdge
|
url
|
||||||
cursor
|
number
|
||||||
node {
|
state
|
||||||
# type: Discussion
|
author {
|
||||||
id
|
url
|
||||||
title # String!
|
|
||||||
bodyText # String!
|
|
||||||
createdViaEmail # Boolean!
|
|
||||||
createdAt # DateTime!
|
|
||||||
answer {
|
|
||||||
#type: DiscussionComment
|
|
||||||
bodyText # String!
|
|
||||||
}
|
|
||||||
comments(first: 10){
|
|
||||||
# type: DiscussionCommentConnection
|
|
||||||
totalCount # Int!
|
|
||||||
edges {
|
|
||||||
# type: DiscussionCommentEdge
|
|
||||||
node {
|
|
||||||
# type: DiscussionComment
|
|
||||||
id
|
|
||||||
bodyText # String!
|
|
||||||
}
|
}
|
||||||
|
labels(first:5) {
|
||||||
|
edges {
|
||||||
|
node {
|
||||||
|
name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
comments(first: 10) {
|
||||||
|
# edges.node is where the actual `Comment` object is
|
||||||
|
edges {
|
||||||
|
node {
|
||||||
|
author {
|
||||||
|
avatarUrl
|
||||||
|
}
|
||||||
|
body
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
body
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
""")
|
""")
|
||||||
@ -60,7 +59,7 @@ def get_discussion_gql(repo_owner, repo_name):
|
|||||||
data_json = json.dumps(data)
|
data_json = json.dumps(data)
|
||||||
headers = {'content-type': 'application/json', 'Accept-Charset': 'UTF-8', 'Authorization': 'bearer ' + key}
|
headers = {'content-type': 'application/json', 'Accept-Charset': 'UTF-8', 'Authorization': 'bearer ' + key}
|
||||||
r = requests.post(url=url, data=data_json, headers=headers)
|
r = requests.post(url=url, data=data_json, headers=headers)
|
||||||
#print(r.content)
|
print(r.content)
|
||||||
return r.json()
|
return r.json()
|
||||||
|
|
||||||
def within_time(comment_content, early_cutoff):
|
def within_time(comment_content, early_cutoff):
|
||||||
@ -79,7 +78,9 @@ def within_time(comment_content, early_cutoff):
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
get_discussion_gql()
|
repo_name = '"' + 'numpy' + '"'
|
||||||
|
repo_owner = '"' + 'numpy' + '"'
|
||||||
|
get_discussion_gql(repo_owner, repo_name)
|
||||||
|
|
||||||
|
|
||||||
# stashed info about page cursors
|
# stashed info about page cursors
|
||||||
@ -90,4 +91,62 @@ if __name__ == "__main__":
|
|||||||
hasNextPage
|
hasNextPage
|
||||||
hasPreviousPage
|
hasPreviousPage
|
||||||
}
|
}
|
||||||
|
'''
|
||||||
|
|
||||||
|
'''
|
||||||
|
issue(number: 2) {
|
||||||
|
title
|
||||||
|
createdAt
|
||||||
|
# first 10 results
|
||||||
|
comments(first: 10) {
|
||||||
|
# edges.node is where the actual `Comment` object is
|
||||||
|
edges {
|
||||||
|
node {
|
||||||
|
author {
|
||||||
|
avatarUrl
|
||||||
|
}
|
||||||
|
body
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
'''
|
||||||
|
|
||||||
|
'''
|
||||||
|
discussions(first: 10) {
|
||||||
|
# type: DiscussionConnection
|
||||||
|
totalCount # Int!
|
||||||
|
|
||||||
|
edges {
|
||||||
|
# type: DiscussionEdge
|
||||||
|
cursor
|
||||||
|
node {
|
||||||
|
# type: Discussion
|
||||||
|
id
|
||||||
|
title # String!
|
||||||
|
bodyText # String!
|
||||||
|
createdViaEmail # Boolean!
|
||||||
|
createdAt # DateTime!
|
||||||
|
answer {
|
||||||
|
#type: DiscussionComment
|
||||||
|
bodyText # String!
|
||||||
|
}
|
||||||
|
comments(first: 10){
|
||||||
|
# type: DiscussionCommentConnection
|
||||||
|
totalCount # Int!
|
||||||
|
edges {
|
||||||
|
# type: DiscussionCommentEdge
|
||||||
|
node {
|
||||||
|
# type: DiscussionComment
|
||||||
|
id
|
||||||
|
bodyText # String!
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
'''
|
'''
|
2
main.py
2
main.py
@ -41,8 +41,10 @@ def main():
|
|||||||
break
|
break
|
||||||
print(largest_object.keys())
|
print(largest_object.keys())
|
||||||
print(len(largest_object.keys()))
|
print(len(largest_object.keys()))
|
||||||
|
'''
|
||||||
for repo in largest_object:
|
for repo in largest_object:
|
||||||
print(largest_object[repo]['new_formality'])
|
print(largest_object[repo]['new_formality'])
|
||||||
|
'''
|
||||||
with open('result.json', 'w') as results_path:
|
with open('result.json', 'w') as results_path:
|
||||||
json.dump(largest_object, results_path)
|
json.dump(largest_object, results_path)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user