Red and blue are passed as (team_id, from)
(conn, round_num, index, red, blue, maps)
| 212 | |
| 213 | |
| 214 | def queue_match(conn, round_num, index, red, blue, maps): |
| 215 | """ |
| 216 | Red and blue are passed as (team_id, from) |
| 217 | """ |
| 218 | red_team, red_from = red |
| 219 | blue_team, blue_from = blue |
| 220 | red_sub = team_submission[red_team] |
| 221 | blue_sub = team_submission[blue_team] |
| 222 | |
| 223 | if red_team is not None and blue_team is not None: |
| 224 | cur = conn.cursor() |
| 225 | |
| 226 | status = 'queued' |
| 227 | query = 'INSERT INTO {} (red_team, blue_team, red_key, blue_key, \ |
| 228 | map, round, index, red_from, blue_from, status) \ |
| 229 | VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)'.format(TABLE_NAME) |
| 230 | |
| 231 | for game_map in maps: |
| 232 | params = (red_team, blue_team, red_sub, blue_sub, |
| 233 | game_map, round_num, index, red_from, blue_from, status) |
| 234 | cur.execute(query, params) |
| 235 | |
| 236 | logging.debug('Round {}, index {}: queued {} vs {}'.format( |
| 237 | round_num, index, red_team, blue_team)) |
| 238 | |
| 239 | cur.close() |
| 240 | else: |
| 241 | cur = conn.cursor() |
| 242 | |
| 243 | winner_id = None |
| 244 | status = 'cancelled' |
| 245 | |
| 246 | if red_team is not None: |
| 247 | red_team, red_from = red |
| 248 | red_sub = team_submission[red_team] |
| 249 | winner_id = red_team |
| 250 | status = 'redwon' |
| 251 | |
| 252 | if blue_team is not None: |
| 253 | blue_team, blue_from = blue |
| 254 | blue_sub = team_submission[blue_team] |
| 255 | winner_id = blue_team |
| 256 | status = 'bluewon' |
| 257 | |
| 258 | query = 'INSERT INTO {} (red_team, blue_team, red_key, blue_key, \ |
| 259 | map, round, index, red_from, blue_from, status) \ |
| 260 | VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)'.format(TABLE_NAME) |
| 261 | |
| 262 | for game_map in maps: |
| 263 | params = (red_team, blue_team, red_sub, blue_sub, |
| 264 | game_map, round_num, index, red_from, blue_from, status) |
| 265 | cur.execute(query, params) |
| 266 | |
| 267 | logging.debug('Round {}, index {}: BYE {} vs {}'.format( |
| 268 | round_num, index, red_team, blue_team)) |
| 269 | |
| 270 | cur.close() |
| 271 |
no test coverage detected