aboutsummaryrefslogtreecommitdiff
path: root/modules/lists/lists.go
diff options
context:
space:
mode:
authorjan <jan@ruken.pw>2015-12-27 20:29:50 (UTC)
committerjan <jan@ruken.pw>2015-12-27 20:29:50 (UTC)
commit0746d945a61ca3dc7588a1f7a2c320ca8a06e198 (patch)
tree0e05e25e640d2e13fee39a713f2373649b5732f4 /modules/lists/lists.go
parentccf10c8d425b28c75cb9ce66c50c943f8825b783 (diff)
dashboard auch für nicht eingeloggte benutzer
Diffstat (limited to 'modules/lists/lists.go')
-rw-r--r--modules/lists/lists.go20
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 {
177func (m *Module) ProvideDashboardData(user *charakterin.User) []grilist.DashboardCategory { 177func (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