diff options
author | Christian Pointner <equinox@helsinki.at> | 2016-01-29 22:58:06 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2016-01-29 22:58:06 (GMT) |
commit | c19af390f2bcd895c6b09215978b68d5894c78eb (patch) | |
tree | 121ab84009b3fb03286d8f09f1561e302d659755 /rddb | |
parent | 780cfc0c66303ac301b88502a0f15723b3e92e98 (diff) |
improved cart listing
Diffstat (limited to 'rddb')
-rw-r--r-- | rddb/rddb.go | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/rddb/rddb.go b/rddb/rddb.go index 29a87af..638c360 100644 --- a/rddb/rddb.go +++ b/rddb/rddb.go @@ -29,6 +29,7 @@ import ( "fmt" "regexp" "strings" + "time" "github.com/ziutek/mymysql/godrv" ) @@ -99,10 +100,25 @@ type getMusicInfoRequest struct { response chan<- getMusicInfoResult } +type CutListEntry struct { + Number uint + Description string +} + +type CartListEntry struct { + Number uint + Title string + Duration time.Duration + Imported time.Time + NumPlayed uint + LastPlayed time.Time + Cuts []*CutListEntry +} + type ShowListEntry struct { ID uint Title string - Carts []uint + Carts []*CartListEntry } type getShowListResult struct { @@ -294,6 +310,13 @@ func (db *DB) getMusicInfo(group string) (result getMusicInfoResult) { return } +func (db *DB) getCartInfo(cart uint) (c *CartListEntry, err error) { + c = &CartListEntry{} + c.Number = cart + c.Title = fmt.Sprintf("Title of Cart: %d", cart) + return +} + func (db *DB) getShowList(username string) (result getShowListResult) { var rows *sql.Rows if rows, result.err = db.getShowListStmt.Query(username, dropboxPseudoStation); result.err != nil { @@ -310,7 +333,18 @@ func (db *DB) getShowList(username string) (result getShowListResult) { return } - show.Carts, result.err = db.getShowCarts(showMacroRe.FindStringSubmatch(macros)[1], lowCart, highCart) + var carts []uint + if carts, result.err = db.getShowCarts(showMacroRe.FindStringSubmatch(macros)[1], lowCart, highCart); result.err != nil { + return + } + + for _, cart := range carts { + var c *CartListEntry + if c, result.err = db.getCartInfo(cart); result.err != nil { + return + } + show.Carts = append(show.Carts, c) + } result.shows = append(result.shows, show) } |