diff options
Diffstat (limited to 'modules/lists')
-rw-r--r-- | modules/lists/lists.go | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/modules/lists/lists.go b/modules/lists/lists.go index 387e48a..05baf4a 100644 --- a/modules/lists/lists.go +++ b/modules/lists/lists.go | |||
@@ -83,6 +83,7 @@ func (m *Module) getListGrils(list *models.List) error { | |||
83 | 83 | ||
84 | defer rows.Close() | 84 | defer rows.Close() |
85 | list.Grils = list.Grils[:0] | 85 | list.Grils = list.Grils[:0] |
86 | var ids []int | ||
86 | for rows.Next() { | 87 | for rows.Next() { |
87 | var grilID int | 88 | var grilID int |
88 | lg := &models.ListGril{} | 89 | lg := &models.ListGril{} |
@@ -91,16 +92,21 @@ func (m *Module) getListGrils(list *models.List) error { | |||
91 | log.Println("error scanning row in getListGrils:", err) | 92 | log.Println("error scanning row in getListGrils:", err) |
92 | continue | 93 | continue |
93 | } | 94 | } |
94 | 95 | ids = append(ids, grilID) | |
95 | gril, err := m.grils.FromID(grilID) | ||
96 | if err != nil { | ||
97 | log.Println("error getting listGril:", err) | ||
98 | continue | ||
99 | } | ||
100 | lg.Gril = gril | ||
101 | 96 | ||
102 | list.Grils = append(list.Grils, lg) | 97 | list.Grils = append(list.Grils, lg) |
103 | } | 98 | } |
99 | |||
100 | // grils holen | ||
101 | grils, err := m.grils.FromIDs(ids) | ||
102 | if err != nil { | ||
103 | return err | ||
104 | } | ||
105 | |||
106 | for id, gril := range grils { | ||
107 | list.Grils[id].Gril = gril | ||
108 | } | ||
109 | |||
104 | sort.Sort(ListGrils(list.Grils)) | 110 | sort.Sort(ListGrils(list.Grils)) |
105 | return nil | 111 | return nil |
106 | } | 112 | } |