@@ -5,54 +5,31 @@ import (
55 "github.com/traggo/server/model"
66)
77
8- func excludedTagsToExternal (tags []model.DashboardExcludedTag ) []* gqlmodel.TimeSpanTag {
8+ func tagFiltersToExternal (tags []model.DashboardTagFilter , include bool ) []* gqlmodel.TimeSpanTag {
99 result := []* gqlmodel.TimeSpanTag {}
1010 for _ , tag := range tags {
11- result = append (result , & gqlmodel.TimeSpanTag {
12- Key : tag .Key ,
13- Value : tag .StringValue ,
14- })
11+ if tag .Include == include {
12+ result = append (result , & gqlmodel.TimeSpanTag {
13+ Key : tag .Key ,
14+ Value : tag .StringValue ,
15+ })
16+ }
1517 }
1618 return result
1719}
1820
19- func ExcludedTagsToInternal (gqls []* gqlmodel.InputTimeSpanTag ) []model.DashboardExcludedTag {
20- result := make ([]model.DashboardExcludedTag , 0 )
21+ func TagFiltersToInternal (gqls []* gqlmodel.InputTimeSpanTag , include bool ) []model.DashboardTagFilter {
22+ result := make ([]model.DashboardTagFilter , 0 )
2123 for _ , tag := range gqls {
22- result = append (result , excludedTagToInternal (* tag ))
24+ result = append (result , tagFilterToInternal (* tag , include ))
2325 }
2426 return result
2527}
2628
27- func excludedTagToInternal (gqls gqlmodel.InputTimeSpanTag ) model.DashboardExcludedTag {
28- return model.DashboardExcludedTag {
29- Key : gqls .Key ,
30- StringValue : gqls .Value ,
31- }
32- }
33-
34- func includedTagsToExternal (tags []model.DashboardIncludedTag ) []* gqlmodel.TimeSpanTag {
35- result := []* gqlmodel.TimeSpanTag {}
36- for _ , tag := range tags {
37- result = append (result , & gqlmodel.TimeSpanTag {
38- Key : tag .Key ,
39- Value : tag .StringValue ,
40- })
41- }
42- return result
43- }
44-
45- func IncludedTagsToInternal (gqls []* gqlmodel.InputTimeSpanTag ) []model.DashboardIncludedTag {
46- result := make ([]model.DashboardIncludedTag , 0 )
47- for _ , tag := range gqls {
48- result = append (result , includedTagToInternal (* tag ))
49- }
50- return result
51- }
52-
53- func includedTagToInternal (gqls gqlmodel.InputTimeSpanTag ) model.DashboardIncludedTag {
54- return model.DashboardIncludedTag {
29+ func tagFilterToInternal (gqls gqlmodel.InputTimeSpanTag , include bool ) model.DashboardTagFilter {
30+ return model.DashboardTagFilter {
5531 Key : gqls .Key ,
5632 StringValue : gqls .Value ,
33+ Include : include ,
5734 }
5835}
0 commit comments