@@ -6,13 +6,14 @@ import (
66)
77
88func (issue * Issue ) ExportData (fields []string ) * map [string ]interface {} {
9+ v := reflect .ValueOf (issue ).Elem ()
910 data := map [string ]interface {}{}
1011
1112 for _ , f := range fields {
1213 switch f {
1314 case "milestone" :
1415 if issue .Milestone .Title != "" {
15- data [f ] = & issue .Milestone
16+ data [f ] = map [ string ] string { "title" : issue .Milestone . Title }
1617 } else {
1718 data [f ] = nil
1819 }
@@ -25,7 +26,6 @@ func (issue *Issue) ExportData(fields []string) *map[string]interface{} {
2526 case "projectCards" :
2627 data [f ] = issue .ProjectCards .Nodes
2728 default :
28- v := reflect .ValueOf (issue ).Elem ()
2929 sf := fieldByName (v , f )
3030 data [f ] = sf .Interface ()
3131 }
@@ -35,6 +35,7 @@ func (issue *Issue) ExportData(fields []string) *map[string]interface{} {
3535}
3636
3737func (pr * PullRequest ) ExportData (fields []string ) * map [string ]interface {} {
38+ v := reflect .ValueOf (pr ).Elem ()
3839 data := map [string ]interface {}{}
3940
4041 for _ , f := range fields {
@@ -43,7 +44,7 @@ func (pr *PullRequest) ExportData(fields []string) *map[string]interface{} {
4344 data [f ] = map [string ]string {"name" : pr .HeadRepository .Name }
4445 case "milestone" :
4546 if pr .Milestone .Title != "" {
46- data [f ] = & pr .Milestone
47+ data [f ] = map [ string ] string { "title" : pr .Milestone . Title }
4748 } else {
4849 data [f ] = nil
4950 }
@@ -75,7 +76,6 @@ func (pr *PullRequest) ExportData(fields []string) *map[string]interface{} {
7576 }
7677 data [f ] = & requests
7778 default :
78- v := reflect .ValueOf (pr ).Elem ()
7979 sf := fieldByName (v , f )
8080 data [f ] = sf .Interface ()
8181 }
@@ -84,22 +84,6 @@ func (pr *PullRequest) ExportData(fields []string) *map[string]interface{} {
8484 return & data
8585}
8686
87- func ExportIssues (issues []Issue , fields []string ) * []interface {} {
88- data := make ([]interface {}, len (issues ))
89- for i := range issues {
90- data [i ] = issues [i ].ExportData (fields )
91- }
92- return & data
93- }
94-
95- func ExportPRs (prs []PullRequest , fields []string ) * []interface {} {
96- data := make ([]interface {}, len (prs ))
97- for i := range prs {
98- data [i ] = prs [i ].ExportData (fields )
99- }
100- return & data
101- }
102-
10387func fieldByName (v reflect.Value , field string ) reflect.Value {
10488 return v .FieldByNameFunc (func (s string ) bool {
10589 return strings .EqualFold (field , s )
0 commit comments