summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2016-02-04 17:08:59 (GMT)
committerChristian Pointner <equinox@helsinki.at>2016-02-04 17:08:59 (GMT)
commit31b15f908c6490217c293d911f70c485de0d1196 (patch)
treebfd99aac56409753ecf098da9b93eebe55d7889f
parentc95d43448cd3fe81a548f693afd0949b25c97556 (diff)
return show list as map with showid as key
-rw-r--r--rddb/rddb.go9
1 files changed, 6 insertions, 3 deletions
diff --git a/rddb/rddb.go b/rddb/rddb.go
index 80cbb38..f1fe580 100644
--- a/rddb/rddb.go
+++ b/rddb/rddb.go
@@ -109,8 +109,10 @@ type ShowListEntry struct {
highCart int
}
+type ShowList map[uint]ShowListEntry
+
type getShowListResult struct {
- shows []ShowListEntry
+ shows ShowList
err error
}
@@ -341,6 +343,7 @@ func (db *DB) getShowList(username string) (result getShowListResult) {
}
defer rows.Close()
+ result.shows = make(map[uint]ShowListEntry)
for rows.Next() {
var show ShowListEntry
var macros, params string
@@ -349,7 +352,7 @@ func (db *DB) getShowList(username string) (result getShowListResult) {
return
}
show.log = showMacroRe.FindStringSubmatch(macros)[1]
- result.shows = append(result.shows, show)
+ result.shows[show.ID] = show
}
result.err = rows.Err()
return
@@ -564,7 +567,7 @@ func (db *DBChan) GetMusicInfo(groupname string) (int, int, error) {
return res.normLvl, res.trimLvl, nil
}
-func (db *DBChan) GetShowList(username string) ([]ShowListEntry, error) {
+func (db *DBChan) GetShowList(username string) (ShowList, error) {
resCh := make(chan getShowListResult)
req := getShowListRequest{}
req.username = username