Simplify issue struct avoiding to sue edges
This commit is contained in:
parent
97cad74d75
commit
1279131f0f
5 changed files with 78 additions and 120 deletions
|
|
@ -34,10 +34,8 @@ type Issue struct {
|
|||
Login string
|
||||
}
|
||||
Assignees struct {
|
||||
Edges []struct {
|
||||
Node struct {
|
||||
Login string
|
||||
}
|
||||
Nodes []struct {
|
||||
Login string
|
||||
}
|
||||
TotalCount int
|
||||
}
|
||||
|
|
@ -48,14 +46,12 @@ type Issue struct {
|
|||
TotalCount int
|
||||
}
|
||||
ProjectCards struct {
|
||||
Edges []struct {
|
||||
Node struct {
|
||||
Project struct {
|
||||
Name string
|
||||
}
|
||||
Column struct {
|
||||
Name string
|
||||
}
|
||||
Nodes []struct {
|
||||
Project struct {
|
||||
Name string
|
||||
}
|
||||
Column struct {
|
||||
Name string
|
||||
}
|
||||
}
|
||||
TotalCount int
|
||||
|
|
@ -64,10 +60,8 @@ type Issue struct {
|
|||
Title string
|
||||
}
|
||||
Participants struct {
|
||||
Edges []struct {
|
||||
Node struct {
|
||||
Login string
|
||||
}
|
||||
Nodes []struct {
|
||||
Login string
|
||||
}
|
||||
TotalCount int
|
||||
}
|
||||
|
|
@ -321,10 +315,8 @@ func IssueByNumber(client *Client, repo ghrepo.Interface, number int) (*Issue, e
|
|||
url
|
||||
createdAt
|
||||
assignees(first: 3) {
|
||||
edges{
|
||||
node {
|
||||
login
|
||||
}
|
||||
nodes {
|
||||
login
|
||||
}
|
||||
totalCount
|
||||
}
|
||||
|
|
@ -335,14 +327,12 @@ func IssueByNumber(client *Client, repo ghrepo.Interface, number int) (*Issue, e
|
|||
totalCount
|
||||
}
|
||||
projectCards(first: 3) {
|
||||
edges{
|
||||
node {
|
||||
project {
|
||||
name
|
||||
}
|
||||
column {
|
||||
name
|
||||
}
|
||||
nodes {
|
||||
project {
|
||||
name
|
||||
}
|
||||
column {
|
||||
name
|
||||
}
|
||||
}
|
||||
totalCount
|
||||
|
|
@ -351,10 +341,8 @@ func IssueByNumber(client *Client, repo ghrepo.Interface, number int) (*Issue, e
|
|||
title
|
||||
}
|
||||
participants(first: 3) {
|
||||
edges{
|
||||
node {
|
||||
login
|
||||
}
|
||||
nodes {
|
||||
login
|
||||
}
|
||||
totalCount
|
||||
}
|
||||
|
|
|
|||
|
|
@ -465,17 +465,17 @@ func printIssues(w io.Writer, prefix string, totalCount int, issues []api.Issue)
|
|||
}
|
||||
|
||||
func assigneeList(issue api.Issue) string {
|
||||
if len(issue.Assignees.Edges) == 0 {
|
||||
if len(issue.Assignees.Nodes) == 1 {
|
||||
return ""
|
||||
}
|
||||
|
||||
AssigneeNames := make([]string, 0, len(issue.Assignees.Edges))
|
||||
for _, assignee := range issue.Assignees.Edges {
|
||||
AssigneeNames = append(AssigneeNames, assignee.Node.Login)
|
||||
AssigneeNames := make([]string, 0, len(issue.Assignees.Nodes))
|
||||
for _, assignee := range issue.Assignees.Nodes {
|
||||
AssigneeNames = append(AssigneeNames, assignee.Login)
|
||||
}
|
||||
|
||||
list := strings.Join(AssigneeNames, ", ")
|
||||
if issue.Assignees.TotalCount > len(issue.Assignees.Edges) {
|
||||
if issue.Assignees.TotalCount > len(issue.Assignees.Nodes) {
|
||||
list += ", …"
|
||||
}
|
||||
return list
|
||||
|
|
@ -499,34 +499,34 @@ func labelList(issue api.Issue) string {
|
|||
}
|
||||
|
||||
func projectList(issue api.Issue) string {
|
||||
if len(issue.ProjectCards.Edges) == 0 {
|
||||
if len(issue.ProjectCards.Nodes) == 0 {
|
||||
return ""
|
||||
}
|
||||
|
||||
projectNames := make([]string, 0, len(issue.ProjectCards.Edges))
|
||||
for _, project := range issue.ProjectCards.Edges {
|
||||
projectNames = append(projectNames, fmt.Sprintf("%s (%s)", project.Node.Project.Name, project.Node.Column.Name))
|
||||
projectNames := make([]string, 0, len(issue.ProjectCards.Nodes))
|
||||
for _, project := range issue.ProjectCards.Nodes {
|
||||
projectNames = append(projectNames, fmt.Sprintf("%s (%s)", project.Project.Name, project.Column.Name))
|
||||
}
|
||||
|
||||
list := strings.Join(projectNames, ", ")
|
||||
if issue.ProjectCards.TotalCount > len(issue.ProjectCards.Edges) {
|
||||
if issue.ProjectCards.TotalCount > len(issue.ProjectCards.Nodes) {
|
||||
list += ", …"
|
||||
}
|
||||
return list
|
||||
}
|
||||
|
||||
func participantList(issue api.Issue) string {
|
||||
if len(issue.Participants.Edges) == 0 {
|
||||
if len(issue.Participants.Nodes) == 0 {
|
||||
return ""
|
||||
}
|
||||
|
||||
participantNames := make([]string, 0, len(issue.Participants.Edges))
|
||||
for _, participant := range issue.Participants.Edges {
|
||||
participantNames = append(participantNames, participant.Node.Login)
|
||||
participantNames := make([]string, 0, len(issue.Participants.Nodes))
|
||||
for _, participant := range issue.Participants.Nodes {
|
||||
participantNames = append(participantNames, participant.Login)
|
||||
}
|
||||
|
||||
list := strings.Join(participantNames, ", ")
|
||||
if issue.Participants.TotalCount > len(issue.Participants.Edges) {
|
||||
if issue.Participants.TotalCount > len(issue.Participants.Nodes) {
|
||||
list += ", …"
|
||||
}
|
||||
return list
|
||||
|
|
|
|||
10
test/fixtures/issueView_preview.json
vendored
10
test/fixtures/issueView_preview.json
vendored
|
|
@ -12,7 +12,7 @@
|
|||
"login": "marseilles"
|
||||
},
|
||||
"assignees": {
|
||||
"edges": [],
|
||||
"nodes": [],
|
||||
"totalcount": 0
|
||||
},
|
||||
"labels": {
|
||||
|
|
@ -20,18 +20,16 @@
|
|||
"totalcount": 0
|
||||
},
|
||||
"projectcards": {
|
||||
"edges": [],
|
||||
"nodes": [],
|
||||
"totalcount": 0
|
||||
},
|
||||
"milestone": {
|
||||
"title": ""
|
||||
},
|
||||
"participants": {
|
||||
"edges": [
|
||||
"nodes": [
|
||||
{
|
||||
"node": {
|
||||
"login": "marseilles"
|
||||
}
|
||||
"login": "marseilles"
|
||||
}
|
||||
],
|
||||
"totalcount": 1
|
||||
|
|
|
|||
|
|
@ -12,20 +12,15 @@
|
|||
"login": "marseilles"
|
||||
},
|
||||
"assignees": {
|
||||
"edges": [
|
||||
{ "node": {
|
||||
"login": "marseilles"
|
||||
}
|
||||
"nodes": [
|
||||
{
|
||||
"login": "marseilles"
|
||||
},
|
||||
{
|
||||
"node": {
|
||||
"login": "monaco"
|
||||
}
|
||||
"login": "monaco"
|
||||
},
|
||||
{
|
||||
"node": {
|
||||
"login": "montpellier"
|
||||
}
|
||||
"login": "montpellier"
|
||||
}
|
||||
],
|
||||
"totalcount": 4
|
||||
|
|
@ -45,35 +40,29 @@
|
|||
"totalcount": 4
|
||||
},
|
||||
"projectcards": {
|
||||
"edges": [
|
||||
"nodes": [
|
||||
{
|
||||
"node": {
|
||||
"project": {
|
||||
"name": "Project 1"
|
||||
},
|
||||
"column": {
|
||||
"name": "column A"
|
||||
}
|
||||
"project": {
|
||||
"name": "Project 1"
|
||||
},
|
||||
"column": {
|
||||
"name": "column A"
|
||||
}
|
||||
},
|
||||
{
|
||||
"node": {
|
||||
"project": {
|
||||
"name": "Project 2"
|
||||
},
|
||||
"column": {
|
||||
"name": "column B"
|
||||
}
|
||||
"project": {
|
||||
"name": "Project 2"
|
||||
},
|
||||
"column": {
|
||||
"name": "column B"
|
||||
}
|
||||
},
|
||||
{
|
||||
"node": {
|
||||
"project": {
|
||||
"name": "Project 3"
|
||||
},
|
||||
"column": {
|
||||
"name": "column C"
|
||||
}
|
||||
"project": {
|
||||
"name": "Project 3"
|
||||
},
|
||||
"column": {
|
||||
"name": "column C"
|
||||
}
|
||||
}
|
||||
],
|
||||
|
|
@ -83,21 +72,15 @@
|
|||
"title": "uluru"
|
||||
},
|
||||
"participants": {
|
||||
"edges": [
|
||||
"nodes": [
|
||||
{
|
||||
"node": {
|
||||
"login": "marseilles"
|
||||
}
|
||||
"login": "marseilles"
|
||||
},
|
||||
{
|
||||
"node": {
|
||||
"login": "monaco"
|
||||
}
|
||||
"login": "monaco"
|
||||
},
|
||||
{
|
||||
"node": {
|
||||
"login": "montpellier"
|
||||
}
|
||||
"login": "montpellier"
|
||||
}
|
||||
],
|
||||
"totalcount": 4
|
||||
|
|
|
|||
39
test/fixtures/issueView_previewWithMetadata.json
vendored
39
test/fixtures/issueView_previewWithMetadata.json
vendored
|
|
@ -12,15 +12,12 @@
|
|||
"login": "marseilles"
|
||||
},
|
||||
"assignees": {
|
||||
"edges": [
|
||||
{ "node": {
|
||||
"login": "marseilles"
|
||||
}
|
||||
"nodes": [
|
||||
{
|
||||
"login": "marseilles"
|
||||
},
|
||||
{
|
||||
"node": {
|
||||
"login": "monaco"
|
||||
}
|
||||
"login": "monaco"
|
||||
}
|
||||
],
|
||||
"totalcount": 2
|
||||
|
|
@ -40,15 +37,13 @@
|
|||
"totalcount": 3
|
||||
},
|
||||
"projectcards": {
|
||||
"edges": [
|
||||
"nodes": [
|
||||
{
|
||||
"node": {
|
||||
"project": {
|
||||
"name": "The GitHub CLI"
|
||||
},
|
||||
"column": {
|
||||
"name": "to do list"
|
||||
}
|
||||
"project": {
|
||||
"name": "The GitHub CLI"
|
||||
},
|
||||
"column": {
|
||||
"name": "to do list"
|
||||
}
|
||||
}
|
||||
],
|
||||
|
|
@ -58,21 +53,15 @@
|
|||
"title": "uluru"
|
||||
},
|
||||
"participants": {
|
||||
"edges": [
|
||||
"nodes": [
|
||||
{
|
||||
"node": {
|
||||
"login": "marseilles"
|
||||
}
|
||||
"login": "marseilles"
|
||||
},
|
||||
{
|
||||
"node": {
|
||||
"login": "monaco"
|
||||
}
|
||||
"login": "monaco"
|
||||
},
|
||||
{
|
||||
"node": {
|
||||
"login": "montpellier"
|
||||
}
|
||||
"login": "montpellier"
|
||||
}
|
||||
],
|
||||
"totalcount": 3
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue