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 c287dc5..65919e8 100644 --- a/modules/lists/lists.go +++ b/modules/lists/lists.go | |||
@@ -78,6 +78,7 @@ func (m *Module) getListGrils(list *models.List) error { | |||
78 | 78 | ||
79 | defer rows.Close() | 79 | defer rows.Close() |
80 | list.Grils = list.Grils[:0] | 80 | list.Grils = list.Grils[:0] |
81 | var ids []int | ||
81 | for rows.Next() { | 82 | for rows.Next() { |
82 | var grilID int | 83 | var grilID int |
83 | lg := &models.ListGril{} | 84 | lg := &models.ListGril{} |
@@ -86,16 +87,21 @@ func (m *Module) getListGrils(list *models.List) error { | |||
86 | log.Println("error scanning row in getListGrils:", err) | 87 | log.Println("error scanning row in getListGrils:", err) |
87 | continue | 88 | continue |
88 | } | 89 | } |
89 | 90 | ids = append(ids, grilID) | |
90 | gril, err := m.grils.FromID(grilID) | ||
91 | if err != nil { | ||
92 | log.Println("error getting listGril:", err) | ||
93 | continue | ||
94 | } | ||
95 | lg.Gril = gril | ||
96 | 91 | ||
97 | list.Grils = append(list.Grils, lg) | 92 | list.Grils = append(list.Grils, lg) |
98 | } | 93 | } |
94 | |||
95 | // grils holen | ||
96 | grils, err := m.grils.FromIDs(ids) | ||
97 | if err != nil { | ||
98 | return err | ||
99 | } | ||
100 | |||
101 | for id, gril := range grils { | ||
102 | list.Grils[id].Gril = gril | ||
103 | } | ||
104 | |||
99 | sort.Sort(ListGrils(list.Grils)) | 105 | sort.Sort(ListGrils(list.Grils)) |
100 | return nil | 106 | return nil |
101 | } | 107 | } |