-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Discussions are limited to 100 results #44
Labels
Comments
This comment was marked as off-topic.
This comment was marked as off-topic.
FWIW, I am/was using the following to compute some statistics from GitHub Discussions (Q&A mostly): OWNER='<owner>'
REPO='<repo>'
CATEGORY='<category-id>'
QUERY='
query($owner: String!, $repo: String!, $category: ID!, $cursor: String) {
repository(owner: $owner, name: $repo) {
discussions(first: 100, after: $cursor, categoryId: $category) {
nodes {
url
category {
name
}
createdAt
updatedAt
answerChosenAt,
comments(first: 1) {
nodes {
createdAt
updatedAt
}
}
}
pageInfo {
hasNextPage
endCursor
}
}
}
}
'
CURSOR=$(gh api graphql -f query="$QUERY" -f owner="$OWNER" -f repo="$REPO" -f category="$CATEGORY" | jq -r '.data.repository.discussions.pageInfo | select(.hasNextPage == true) | .endCursor')
RESULTS='[]'
ipage=0
while true; do
ipage=$((ipage + 1))
echo "Page: $ipage"
RESPONSE=$(gh api graphql -f query="$QUERY" -f owner="$OWNER" -f repo="$REPO" -f category="$CATEGORY" -f cursor="$CURSOR")
RESULTS=$(echo "$RESULTS" | jq --argjson response "$RESPONSE" '. + $response.data.repository.discussions.nodes')
CURSOR=$(echo "$RESPONSE" | jq -r '.data.repository.discussions.pageInfo | select(.hasNextPage == true) | .endCursor')
if [ "$CURSOR" = "" ]; then
break
fi
done
echo "$RESULTS" | jq 'map({url: .url, category: .category.name, createdAt: .createdAt, updatedAt: .updatedAt, answerChosenAt: .answerChosenAt, commentCreatedAt: .comments.nodes[0].createdAt, commentUpdatedAt: .comments.nodes[0].updatedAt})' > discussions.json Where the categories ID can be retrieved with: OWNER='<owner>'
REPO='<repo>'
gh api graphql -f query='
query($owner: String!, $repo: String!) {
repository(owner: $owner, name: $repo) {
discussionCategories(first: 10) {
nodes {
id
name
}
}
}
}
' -f owner="$OWNER" -f repo="$REPO" | jq '.data.repository.discussionCategories.nodes' |
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This issue is stale because it has been open 21 days with no activity. Remove stale label or comment or this will be closed in 14 days. |
5 tasks
Jalmeida1994
added a commit
to Jalmeida1994/issue-metrics
that referenced
this issue
Nov 27, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Seems like some folks might want this to be increased to measure metrics on more than 100 discussions. We could either implement a more reasonable limit or figure out how to handle paging up to the limit of github search results.
The text was updated successfully, but these errors were encountered: