diff options
author | Christian Pointner <equinox@helsinki.at> | 2016-02-04 17:08:59 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2016-02-04 17:08:59 (GMT) |
commit | 31b15f908c6490217c293d911f70c485de0d1196 (patch) | |
tree | bfd99aac56409753ecf098da9b93eebe55d7889f /rddb | |
parent | c95d43448cd3fe81a548f693afd0949b25c97556 (diff) |
return show list as map with showid as key
Diffstat (limited to 'rddb')
-rw-r--r-- | rddb/rddb.go | 9 |
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 |