aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjan <jan@ruken.pw>2015-12-28 21:36:35 (UTC)
committerjan <jan@ruken.pw>2015-12-28 21:36:35 (UTC)
commit6ffa881ed739d62ec36b0d5bf0bf8f4f179d62b5 (patch)
treed699eb62f3946691eb85b787a4c355b2b8aa0224
parentd3c49b165825369ce5bbd1efbbad2afab39e7cda (diff)
versuchen, die performance zu erhöhen indem wir nicht grils_flattened für updated_at verwenden, weil das view extrem langsam ist.
-rw-r--r--modules/grils/grils.go18
1 files changed, 15 insertions, 3 deletions
diff --git a/modules/grils/grils.go b/modules/grils/grils.go
index a38f41f..8ec7bcb 100644
--- a/modules/grils/grils.go
+++ b/modules/grils/grils.go
@@ -97,17 +97,30 @@ func (m *GrilsModule) GetListsOfGril(gril *Gril) error {
97func (m *GrilsModule) ProvideDashboardData(user *charakterin.User) []grilist.DashboardCategory { 97func (m *GrilsModule) ProvideDashboardData(user *charakterin.User) []grilist.DashboardCategory {
98 var categories []grilist.DashboardCategory 98 var categories []grilist.DashboardCategory
99 99
100 grils, err := m.getGrils(`1 = 1 ORDER BY updated_at DESC LIMIT 5`) 100 rows, err := m.g.DB.Query(`SELECT id FROM grilist.grils ORDER BY updated_at DESC LIMIT 5`)
101 if err != nil { 101 if err != nil {
102 log.Println(err) 102 log.Println(err)
103 return categories 103 return categories
104 } 104 }
105 defer rows.Close()
105 106
106 cat := grilist.DashboardCategory{ 107 cat := grilist.DashboardCategory{
107 Title: "Neue Grils", 108 Title: "Neue Grils",
108 } 109 }
109 110
110 for _, gril := range grils { 111 for rows.Next() {
112 var id int
113 if err := rows.Scan(&id); err != nil {
114 log.Println(err)
115 continue
116 }
117
118 gril, err := m.FromID(id)
119 if err != nil {
120 log.Println(err)
121 continue
122 }
123
111 cat.Cards = append(cat.Cards, frontend.Card{ 124 cat.Cards = append(cat.Cards, frontend.Card{
112 Title: gril.RomajiName, 125 Title: gril.RomajiName,
113 Description: gril.KanjiName, 126 Description: gril.KanjiName,
@@ -120,7 +133,6 @@ func (m *GrilsModule) ProvideDashboardData(user *charakterin.User) []grilist.Das
120 }, 133 },
121 }) 134 })
122 } 135 }
123
124 categories = append(categories, cat) 136 categories = append(categories, cat)
125 return categories 137 return categories
126} 138}