Discussions are limited to 100 results
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.
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.
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'
y
- @https://1drv.ms/f/s!AiQfd2NdVtYvZ0Fo_LEqhgheQz0
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.