MCPcopy Create free account
hub / github.com/cli/cli / mapDiscussionFromListNode

Function mapDiscussionFromListNode

pkg/cmd/discussion/client/client.go:140–176  ·  view source on GitHub ↗

mapDiscussionFromListNode converts a discussionListNode into the domain Discussion type.

(n discussionListNode)

Source from the content-addressed store, hash-verified

138
139// mapDiscussionFromListNode converts a discussionListNode into the domain Discussion type.
140func mapDiscussionFromListNode(n discussionListNode) Discussion {
141 d := Discussion{
142 ID: n.ID,
143 Number: n.Number,
144 Title: n.Title,
145 Body: n.Body,
146 URL: n.URL,
147 Closed: n.Closed,
148 StateReason: n.StateReason,
149 Author: mapActorFromListNode(n.Author),
150 Category: DiscussionCategory{
151 ID: n.Category.ID,
152 Name: n.Category.Name,
153 Slug: n.Category.Slug,
154 Emoji: n.Category.Emoji,
155 IsAnswerable: n.Category.IsAnswerable,
156 },
157 Answered: n.IsAnswered,
158 AnswerChosenAt: n.AnswerChosenAt,
159 CreatedAt: n.CreatedAt,
160 UpdatedAt: n.UpdatedAt,
161 ClosedAt: n.ClosedAt,
162 Locked: n.Locked,
163 }
164
165 if n.AnswerChosenBy != nil {
166 a := mapActorFromListNode(*n.AnswerChosenBy)
167 d.AnswerChosenBy = &a
168 }
169
170 d.Labels = make([]DiscussionLabel, len(n.Labels.Nodes))
171 for i, l := range n.Labels.Nodes {
172 d.Labels[i] = DiscussionLabel{ID: l.ID, Name: l.Name, Color: l.Color}
173 }
174
175 return d
176}
177
178func (c *discussionClient) List(repo ghrepo.Interface, filters ListFilters, after string, limit int) (*DiscussionListResult, error) {
179 if limit <= 0 {

Callers 7

ListMethod · 0.85
SearchMethod · 0.85
GetByNumberMethod · 0.85
GetWithCommentsMethod · 0.85
GetCommentRepliesMethod · 0.85
CreateMethod · 0.85
UpdateMethod · 0.85

Calls 1

mapActorFromListNodeFunction · 0.85

Tested by

no test coverage detected