aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modules/grils/grils.go24
1 files changed, 8 insertions, 16 deletions
diff --git a/modules/grils/grils.go b/modules/grils/grils.go
index 3ff03ec..135398d 100644
--- a/modules/grils/grils.go
+++ b/modules/grils/grils.go
@@ -105,43 +105,35 @@ func (m *GrilsModule) GetListsOfGril(gril *Gril) error {
105 105
106func (m *GrilsModule) ProvideDashboardData(user *charakterin.User) []grilist.DashboardCategory { 106func (m *GrilsModule) ProvideDashboardData(user *charakterin.User) []grilist.DashboardCategory {
107 var categories []grilist.DashboardCategory 107 var categories []grilist.DashboardCategory
108
109 t1 := time.Now() 108 t1 := time.Now()
110 rows, err := m.g.DB.Query(`SELECT id FROM grilist.grils ORDER BY updated_at DESC LIMIT 5`) 109
110 rows, err := m.g.DB.Query(
111 `SELECT id, romaji_name, kanji_name FROM grilist.get_recently_updated_grils();`)
111 if err != nil { 112 if err != nil {
112 log.Println(err) 113 log.Println(err)
113 return categories 114 return categories
114 } 115 }
115 defer rows.Close() 116 defer rows.Close()
116 log.Printf("get_newest_grils: %dms", time.Since(t1).Nanoseconds()/1000000)
117 117
118 cat := grilist.DashboardCategory{ 118 cat := grilist.DashboardCategory{
119 Title: "Neue Grils", 119 Title: "Neue Grils",
120 } 120 }
121 121
122 for rows.Next() { 122 for rows.Next() {
123 var id int 123 var g Gril
124 if err := rows.Scan(&id); err != nil { 124 if err := rows.Scan(&g.ID, &g.RomajiName, &g.KanjiName); err != nil {
125 log.Println(err)
126 continue
127 }
128
129 t2 := time.Now()
130 gril, err := m.FromID(id)
131 if err != nil {
132 log.Println(err) 125 log.Println(err)
133 continue 126 continue
134 } 127 }
135 log.Printf("get_gril_from_id_in_newest_grils: %dms", time.Since(t2).Nanoseconds()/1000000)
136 128
137 cat.Cards = append(cat.Cards, frontend.Card{ 129 cat.Cards = append(cat.Cards, frontend.Card{
138 Title: gril.RomajiName, 130 Title: g.RomajiName,
139 Description: gril.KanjiName, 131 Description: g.KanjiName,
140 Size: "medium", 132 Size: "medium",
141 Actions: []frontend.Action{ 133 Actions: []frontend.Action{
142 frontend.Action{ 134 frontend.Action{
143 Name: "anguckieren", 135 Name: "anguckieren",
144 Link: "/gril/" + gril.Slug(), 136 Link: "/gril/" + g.Slug(),
145 }, 137 },
146 }, 138 },
147 }) 139 })