Skip to content

Return assignees with issues queries #479

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

Merged
merged 3 commits into from
Jun 25, 2025

Conversation

itsgareth
Copy link
Contributor

Return a new column in the issues query: Assignees. This change allows users to see who is assigned to each GitHub issue directly in their Grafana dashboards and queries.

BEFORE THE CHANGE
Screenshot 2025-06-20 at 17 27 35

AFTER THE CHANGE
Screenshot 2025-06-20 at 17 26 47

@itsgareth itsgareth self-assigned this Jun 20, 2025
@itsgareth itsgareth requested a review from a team as a code owner June 20, 2025 16:31
@itsgareth itsgareth requested review from Copilot and itsmylife June 20, 2025 16:31
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a new Assignees column to the issues query, so consumers can see who is assigned on each GitHub issue in Grafana dashboards.

  • Extend the GraphQL Issue model and Frames() logic to serialize assignees into the dataframe.
  • Update unit tests to include various assignee scenarios.
  • Refresh the golden JSON fixture to reflect the new column.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
pkg/github/issues.go Added Assignees in the Issue struct and appended its JSON field in Frames().
pkg/github/issues_test.go Populated and asserted the new Assignees nodes in test cases.
pkg/github/testdata/issues.golden.jsonc Updated comments, schema, and example rows to include assignees.
Comments suppressed due to low confidence (1)

pkg/github/issues.go:33

  • The GraphQL query limits assignees to the first 10, while labels use a limit of 100. Consider increasing this (e.g., first: 100) or making it configurable to avoid missing assignees on issues with more than 10.
	} `graphql:"assignees(first: 10)"`

Comment on lines 77 to +80
labelsBytes, _ := json.Marshal(labels)
rawLabelArray := json.RawMessage(labelsBytes)

assigneesBytes, _ := json.Marshal(assignees)
Copy link
Preview

Copilot AI Jun 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ignoring the error returned by json.Marshal can mask serialization failures. Consider capturing and handling or logging the error to aid troubleshooting.

Suggested change
labelsBytes, _ := json.Marshal(labels)
rawLabelArray := json.RawMessage(labelsBytes)
assigneesBytes, _ := json.Marshal(assignees)
labelsBytes, err := json.Marshal(labels)
if err != nil {
fmt.Printf("Error marshaling labels for issue %d: %v\n", v.Number, err)
continue
}
rawLabelArray := json.RawMessage(labelsBytes)
assigneesBytes, err := json.Marshal(assignees)
if err != nil {
fmt.Printf("Error marshaling assignees for issue %d: %v\n", v.Number, err)
continue
}

Copilot uses AI. Check for mistakes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we go with array of strings, then we probably don't need this logic.

@sympatheticmoose
Copy link
Contributor

Just in case this goes beyond POC - please ensure to update the docs https://github.com/grafana/github-datasource/blob/main/docs/sources/query/_index.md#issues

Comment on lines 77 to +80
labelsBytes, _ := json.Marshal(labels)
rawLabelArray := json.RawMessage(labelsBytes)

assigneesBytes, _ := json.Marshal(assignees)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we go with array of strings, then we probably don't need this logic.

@itsgareth itsgareth changed the title POC: return assignees with issues queries Return assignees with issues queries Jun 25, 2025
@itsgareth itsgareth merged commit d7abcb6 into main Jun 25, 2025
17 checks passed
@itsgareth itsgareth deleted the gareth/return-assignee-on-issues branch June 25, 2025 13:31
@github-project-automation github-project-automation bot moved this to Complete in OSS Big Tent Jun 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Complete
Development

Successfully merging this pull request may close these issues.

3 participants