aboutsummaryrefslogtreecommitdiff
path: root/modules/lists
diff options
context:
space:
mode:
authorjan <jan@ruken.pw>2016-11-14 20:55:41 (UTC)
committerjan <jan@ruken.pw>2016-11-14 20:55:41 (UTC)
commite02ad854383265db216ed92b10c4f12408999d6a (patch)
treef9622d16b369ce0202d38b4c6ede7c4cde4f591f /modules/lists
parentf5eb019e0883e4bbacd762ab2ab1a4647e74e750 (diff)
grilist wieder schnell machen
Diffstat (limited to 'modules/lists')
-rw-r--r--modules/lists/lists.go20
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}