| Conditions | 2 |
| Paths | 2 |
| Total Lines | 23 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 12 |
| CRAP Score | 2.0116 |
| Changes | 0 | ||
| 1 | <?php |
||
| 7 | 1 | public function up() |
|
| 8 | { |
||
| 9 | 1 | $playersTable = $this->table('players'); |
|
| 10 | $playersTable |
||
| 11 | 1 | ->addColumn('last_match', 'integer', array( |
|
| 12 | 1 | 'signed' => false, |
|
| 13 | 1 | 'limit' => 10, |
|
| 14 | 1 | 'null' => true, |
|
| 15 | 'comment' => 'The timestamp of the last match this player participated in' |
||
| 16 | 1 | )) |
|
| 17 | 1 | ->addForeignKey('last_match', 'matches', 'id', array('delete' => 'SET_NULL')) |
|
| 18 | 1 | ->update(); |
|
| 19 | |||
| 20 | 1 | $players = $this->fetchAll('SELECT id FROM players'); |
|
| 21 | |||
| 22 | 1 | foreach ($players as $player) { |
|
| 23 | $this->query( |
||
| 24 | "UPDATE players SET last_match = ( |
||
| 25 | SELECT id FROM matches WHERE FIND_IN_SET(${player['id']}, team_a_players) OR FIND_IN_SET(${player['id']}, team_b_players) ORDER BY timestamp DESC LIMIT 1 |
||
| 26 | ) WHERE id = " . $player['id'] |
||
| 27 | ); |
||
| 28 | } |
||
| 29 | 1 | } |
|
| 30 | |||
| 40 |