diff options
Diffstat (limited to 'modules/lists')
-rw-r--r-- | modules/lists/lists.go | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/modules/lists/lists.go b/modules/lists/lists.go index a7e822a..154bf74 100644 --- a/modules/lists/lists.go +++ b/modules/lists/lists.go | |||
@@ -177,29 +177,33 @@ func rowsToCard(rows *sql.Rows) []frontend.Card { | |||
177 | func (m *Module) ProvideDashboardData(user *charakterin.User) []grilist.DashboardCategory { | 177 | func (m *Module) ProvideDashboardData(user *charakterin.User) []grilist.DashboardCategory { |
178 | var categories []grilist.DashboardCategory | 178 | var categories []grilist.DashboardCategory |
179 | 179 | ||
180 | // Listen des Benutzers | 180 | // Neue Listen |
181 | rows, err := m.g.DB.Query(`SELECT id, name, description FROM grilist.lists WHERE user_id = $1`, user.ID) | 181 | rows, err := m.g.DB.Query(`SELECT id, name, description FROM grilist.lists ORDER BY id DESC LIMIT 5`) |
182 | if err != nil { | 182 | if err != nil { |
183 | log.Println(err) | 183 | log.Println(err) |
184 | return []grilist.DashboardCategory{} | 184 | return categories |
185 | } | 185 | } |
186 | defer rows.Close() | 186 | defer rows.Close() |
187 | 187 | ||
188 | categories = append(categories, grilist.DashboardCategory{ | 188 | categories = append(categories, grilist.DashboardCategory{ |
189 | Title: "Meine Listen", | 189 | Title: "Neueste Listen", |
190 | Cards: rowsToCard(rows), | 190 | Cards: rowsToCard(rows), |
191 | }) | 191 | }) |
192 | 192 | ||
193 | // Neue Listen | 193 | if user == nil { |
194 | rows, err = m.g.DB.Query(`SELECT id, name, description FROM grilist.lists ORDER BY id DESC LIMIT 5`) | 194 | return categories |
195 | } | ||
196 | |||
197 | // Listen des Benutzers | ||
198 | rows, err = m.g.DB.Query(`SELECT id, name, description FROM grilist.lists WHERE user_id = $1`, user.ID) | ||
195 | if err != nil { | 199 | if err != nil { |
196 | log.Println(err) | 200 | log.Println(err) |
197 | return categories | 201 | return []grilist.DashboardCategory{} |
198 | } | 202 | } |
199 | defer rows.Close() | 203 | defer rows.Close() |
200 | 204 | ||
201 | categories = append(categories, grilist.DashboardCategory{ | 205 | categories = append(categories, grilist.DashboardCategory{ |
202 | Title: "Neueste Listen", | 206 | Title: "Meine Listen", |
203 | Cards: rowsToCard(rows), | 207 | Cards: rowsToCard(rows), |
204 | }) | 208 | }) |
205 | 209 | ||