summaryrefslogtreecommitdiff
path: root/rddb
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2016-07-08 15:34:21 (GMT)
committerChristian Pointner <equinox@helsinki.at>2016-07-08 15:34:21 (GMT)
commit5b0999d52e6030b404af0558fb0a7d9a36219db4 (patch)
tree41128d72abd2b87933c17ef09f82f8b076ed9c31 /rddb
parentbfe8b6de150b9da1959b763530c5490cc6e5426c (diff)
added interface to update Cut and possible Cart title to rddb and importer
Diffstat (limited to 'rddb')
-rw-r--r--rddb/rddb.go118
1 files changed, 80 insertions, 38 deletions
diff --git a/rddb/rddb.go b/rddb/rddb.go
index 4edda6a..6b78009 100644
--- a/rddb/rddb.go
+++ b/rddb/rddb.go
@@ -27,6 +27,7 @@ package rddb
import (
"database/sql"
"fmt"
+ "path/filepath"
"regexp"
"strconv"
"strings"
@@ -207,34 +208,47 @@ type getPoolCartListRequest struct {
response chan<- getPoolCartListResult
}
+type updateCutCartTitleResult struct {
+ err error
+}
+
+type updateCutCartTitleRequest struct {
+ cart uint
+ cut uint
+ groupName string
+ sourceFile string
+ response chan<- updateCutCartTitleResult
+}
+
type DB struct {
- conf *config
- dbh *sql.DB
- passwordCache map[string]string
- getPasswordChan chan getPasswordRequest
- getPasswordStmt *sql.Stmt
- getGroupOfCartChan chan getGroupOfCartRequest
- getGroupOfCartStmt *sql.Stmt
- getShowInfoChan chan getShowInfoRequest
- getShowInfoStmt *sql.Stmt
- checkMusicGroupChan chan checkMusicGroupRequest
- checkMusicGroupStmt *sql.Stmt
- getMusicInfoChan chan getMusicInfoRequest
- getMusicInfoStmt *sql.Stmt
- getShowListChan chan getShowListRequest
- getShowListStmt *sql.Stmt
- getShowCartListChan chan getShowCartListRequest
- getCartInfoStmt *sql.Stmt
- getCutInfoStmt *sql.Stmt
- getJingleListChan chan getJingleListRequest
- getJingleListStmt *sql.Stmt
- getJingleCutListChan chan getJingleCutListRequest
- getPoolListChan chan getPoolListRequest
- getPoolListStmt *sql.Stmt
- getPoolCartListChan chan getPoolCartListRequest
- getPoolCartsStmt *sql.Stmt
- quit chan bool
- done chan bool
+ conf *config
+ dbh *sql.DB
+ passwordCache map[string]string
+ getPasswordChan chan getPasswordRequest
+ getPasswordStmt *sql.Stmt
+ getGroupOfCartChan chan getGroupOfCartRequest
+ getGroupOfCartStmt *sql.Stmt
+ getShowInfoChan chan getShowInfoRequest
+ getShowInfoStmt *sql.Stmt
+ checkMusicGroupChan chan checkMusicGroupRequest
+ checkMusicGroupStmt *sql.Stmt
+ getMusicInfoChan chan getMusicInfoRequest
+ getMusicInfoStmt *sql.Stmt
+ getShowListChan chan getShowListRequest
+ getShowListStmt *sql.Stmt
+ getShowCartListChan chan getShowCartListRequest
+ getCartInfoStmt *sql.Stmt
+ getCutInfoStmt *sql.Stmt
+ getJingleListChan chan getJingleListRequest
+ getJingleListStmt *sql.Stmt
+ getJingleCutListChan chan getJingleCutListRequest
+ getPoolListChan chan getPoolListRequest
+ getPoolListStmt *sql.Stmt
+ getPoolCartListChan chan getPoolCartListRequest
+ getPoolCartsStmt *sql.Stmt
+ updateCutCartTitleChan chan updateCutCartTitleRequest
+ quit chan bool
+ done chan bool
}
func (db *DB) init() (err error) {
@@ -618,6 +632,15 @@ func (db *DB) getPoolCartList(pool PoolListEntry) (result getPoolCartListResult)
return
}
+func (db *DB) updateCutCartTitle(cart, cut uint, groupName, sourceFile string) (result updateCutCartTitleResult) {
+ path, filename := filepath.Split(sourceFile)
+ ext := strings.TrimLeft(filepath.Ext(filename), ".")
+ filename = strings.TrimRight(strings.TrimSuffix(filename, ext), ".")
+
+ result.err = fmt.Errorf(" new CUT/CART/GROUP (%d/%d/%s) Title: %%p -> '%s', %%f -> '%s', %%e -> '%s'", cart, cut, groupName, path, filename, ext)
+ return
+}
+
func (db *DB) dispatchRequests() {
defer func() { db.done <- true }()
for {
@@ -646,6 +669,8 @@ func (db *DB) dispatchRequests() {
req.response <- db.getPoolList(req.username)
case req := <-db.getPoolCartListChan:
req.response <- db.getPoolCartList(req.pool)
+ case req := <-db.updateCutCartTitleChan:
+ req.response <- db.updateCutCartTitle(req.cart, req.cut, req.groupName, req.sourceFile)
}
}
}
@@ -654,17 +679,18 @@ func (db *DB) dispatchRequests() {
// Public Interface
type DBChan struct {
- getPasswordChan chan<- getPasswordRequest
- getGroupOfCartChan chan<- getGroupOfCartRequest
- getShowInfoChan chan<- getShowInfoRequest
- checkMusicGroupChan chan<- checkMusicGroupRequest
- getMusicInfoChan chan<- getMusicInfoRequest
- getShowListChan chan<- getShowListRequest
- getShowCartListChan chan<- getShowCartListRequest
- getJingleListChan chan<- getJingleListRequest
- getJingleCutListChan chan<- getJingleCutListRequest
- getPoolListChan chan<- getPoolListRequest
- getPoolCartListChan chan<- getPoolCartListRequest
+ getPasswordChan chan<- getPasswordRequest
+ getGroupOfCartChan chan<- getGroupOfCartRequest
+ getShowInfoChan chan<- getShowInfoRequest
+ checkMusicGroupChan chan<- checkMusicGroupRequest
+ getMusicInfoChan chan<- getMusicInfoRequest
+ getShowListChan chan<- getShowListRequest
+ getShowCartListChan chan<- getShowCartListRequest
+ getJingleListChan chan<- getJingleListRequest
+ getJingleCutListChan chan<- getJingleCutListRequest
+ getPoolListChan chan<- getPoolListRequest
+ getPoolCartListChan chan<- getPoolCartListRequest
+ updateCutCartTitleChan chan<- updateCutCartTitleRequest
}
func (db *DBChan) GetPassword(username string, cached bool) (string, error) {
@@ -846,6 +872,20 @@ func (db *DBChan) GetPoolCartList(pool PoolListEntry) (map[uint]CartListEntry, e
return res.carts, nil
}
+func (db *DBChan) UpdateCutCartTitle(cart, cut uint, groupName, sourceFile string) error {
+ resCh := make(chan updateCutCartTitleResult)
+ req := updateCutCartTitleRequest{}
+ req.cart = cart
+ req.cut = cut
+ req.groupName = groupName
+ req.sourceFile = sourceFile
+ req.response = resCh
+ db.updateCutCartTitleChan <- req
+
+ res := <-resCh
+ return res.err
+}
+
func (db *DB) GetInterface() *DBChan {
ch := &DBChan{}
ch.getPasswordChan = db.getPasswordChan
@@ -859,6 +899,7 @@ func (db *DB) GetInterface() *DBChan {
ch.getJingleCutListChan = db.getJingleCutListChan
ch.getPoolListChan = db.getPoolListChan
ch.getPoolCartListChan = db.getPoolCartListChan
+ ch.updateCutCartTitleChan = db.updateCutCartTitleChan
return ch
}
@@ -925,6 +966,7 @@ func NewDB(configfile string) (db *DB, err error) {
db.getJingleCutListChan = make(chan getJingleCutListRequest, 10)
db.getPoolListChan = make(chan getPoolListRequest, 10)
db.getPoolCartListChan = make(chan getPoolCartListRequest, 10)
+ db.updateCutCartTitleChan = make(chan updateCutCartTitleRequest, 10)
if err = db.init(); err != nil {
return