summaryrefslogtreecommitdiff
path: root/src/helsinki.at/rhimport/rddb.go
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2015-12-26 09:52:33 (GMT)
committerChristian Pointner <equinox@helsinki.at>2015-12-26 09:52:33 (GMT)
commita03a9cf4b5b34a54d715a518b83919bb322c42c3 (patch)
tree34f4db05ce9fa2cf66d96e1e63dcbb0cf276c680 /src/helsinki.at/rhimport/rddb.go
parent62ebc38acc54335ed7c4b14551fae828efddc333 (diff)
small refactoring
Diffstat (limited to 'src/helsinki.at/rhimport/rddb.go')
-rw-r--r--src/helsinki.at/rhimport/rddb.go73
1 files changed, 72 insertions, 1 deletions
diff --git a/src/helsinki.at/rhimport/rddb.go b/src/helsinki.at/rhimport/rddb.go
index 7466d9c..ead1ac0 100644
--- a/src/helsinki.at/rhimport/rddb.go
+++ b/src/helsinki.at/rhimport/rddb.go
@@ -177,7 +177,22 @@ func (self *RdDb) getPassword(username string, cached bool) (result getPasswordR
return
}
-func (self *RdDbChan) CheckPassword(username, password string) (result bool, err error) {
+func (self *RdDbChan) GetPassword(username string, cached bool) (string, error) {
+ res_ch := make(chan getPasswordResult)
+ req := getPasswordRequest{}
+ req.username = username
+ req.cached = cached
+ req.response = res_ch
+ self.getPasswordChan <- req
+
+ res := <-res_ch
+ if res.err != nil {
+ return "", res.err
+ }
+ return res.password, nil
+}
+
+func (self *RdDbChan) CheckPassword(username, password string) (bool, error) {
cached := true
for {
@@ -234,6 +249,20 @@ func (self *RdDb) getGroupOfCart(cart uint) (result getGroupOfCartResult) {
return
}
+func (self *RdDbChan) GetGroupOfCart(cart uint) (string, error) {
+ res_ch := make(chan getGroupOfCartResult)
+ req := getGroupOfCartRequest{}
+ req.cart = cart
+ req.response = res_ch
+ self.getGroupOfCartChan <- req
+
+ res := <-res_ch
+ if res.err != nil {
+ return "", res.err
+ }
+ return res.group, nil
+}
+
func (self *RdDb) getLogTableName(log string) (logtable string, err error) {
logtable = strings.Replace(log, " ", "_", -1) + "_LOG"
if !mysqlTableNameRe.MatchString(logtable) {
@@ -280,6 +309,20 @@ func (self *RdDb) getShowInfo(showid uint) (result getShowInfoResult) {
return
}
+func (self *RdDbChan) GetShowInfo(showid uint) (string, int, int, []uint, error) {
+ res_ch := make(chan getShowInfoResult)
+ req := getShowInfoRequest{}
+ req.showid = showid
+ req.response = res_ch
+ self.getShowInfoChan <- req
+
+ res := <-res_ch
+ if res.err != nil {
+ return "", 0, 0, nil, res.err
+ }
+ return res.group, res.norm_lvl, res.trim_lvl, res.carts, nil
+}
+
func (self *RdDb) checkMusicGroup(group string) (result checkMusicGroupResult) {
var cnt int
if result.err = self.checkMusicGroupStmt.QueryRow(group).Scan(&cnt); result.err != nil {
@@ -293,6 +336,20 @@ func (self *RdDb) checkMusicGroup(group string) (result checkMusicGroupResult) {
return
}
+func (self *RdDbChan) CheckMusicGroup(groupname string) (bool, error) {
+ res_ch := make(chan checkMusicGroupResult)
+ req := checkMusicGroupRequest{}
+ req.group = groupname
+ req.response = res_ch
+ self.checkMusicGroupChan <- req
+
+ res := <-res_ch
+ if res.err != nil {
+ return false, res.err
+ }
+ return res.ismusic, nil
+}
+
func (self *RdDb) getMusicInfo(group string) (result getMusicInfoResult) {
result.err = self.getMusicInfoStmt.QueryRow(group).Scan(&result.norm_lvl, &result.trim_lvl)
if result.err != nil {
@@ -304,6 +361,20 @@ func (self *RdDb) getMusicInfo(group string) (result getMusicInfoResult) {
return
}
+func (self *RdDbChan) GetMusicInfo(groupname string) (int, int, error) {
+ res_ch := make(chan getMusicInfoResult)
+ req := getMusicInfoRequest{}
+ req.group = groupname
+ req.response = res_ch
+ self.getMusicInfoChan <- req
+
+ res := <-res_ch
+ if res.err != nil {
+ return 0, 0, res.err
+ }
+ return res.norm_lvl, res.trim_lvl, nil
+}
+
func (self *RdDb) dispatchRequests() {
defer func() { self.done <- true }()
for {