Commit 1df6097a authored by Frederik Wegner's avatar Frederik Wegner

Partially moved matching pools check from sql query to golang upon weird sql bugs.

parent 8447e28a
Pipeline #1673 passed with stage
in 5 minutes and 22 seconds
...@@ -323,10 +323,19 @@ func (m *MySQLDuelQuery) Insert(challengerID, challengedID uint32) (*schemas.Due ...@@ -323,10 +323,19 @@ func (m *MySQLDuelQuery) Insert(challengerID, challengedID uint32) (*schemas.Due
if cUsers != 1 { if cUsers != 1 {
return nil, ErrUserNotFound return nil, ErrUserNotFound
} }
queryCommonPools := "SELECT DISTINCT pool from user_pool where user=? and pool in (select pool from user_pool where user=?)" queryCommonPools := "SELECT Q.user FROM (SELECT * FROM user_pool WHERE pool IN (SELECT pool FROM user_pool WHERE user=?)) AS Q"
// check that at least one pool exists that both players have selected // check if the other uses is in the list of users hat have a common pool
resQueryCommonPools, errQueryCommonPools := db.Query(queryCommonPools, challengerID, challengedID) resQueryCommonPools, errQueryCommonPools := db.Query(queryCommonPools, challengerID)
if errQueryCommonPools != nil || !resQueryCommonPools.Next() { var uID uint32
found := false
for resQueryCommonPools.Next() {
if uID == challengedID {
found = true
if errQueryCommonPools != nil || !found {
return nil, ErrNoCommonPool return nil, ErrNoCommonPool
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment