Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
18 / 18 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| SGFProposalsRenderer | |
100.00% |
17 / 17 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
1 | |||
| renderItem | |
100.00% |
12 / 12 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | App::uses('DataTableRenderer', 'Utility'); |
| 4 | |
| 5 | class SGFProposalsRenderer extends DataTableRenderer |
| 6 | { |
| 7 | public function __construct($urlParams) |
| 8 | { |
| 9 | $this->count = Util::query("SELECT COUNT(DISTINCT tsumego_id) as total FROM sgf WHERE accepted = false")[0]['total']; |
| 10 | parent::__construct($urlParams, 'sgf_proposals_page', 'SGF Proposals'); |
| 11 | $this->data = Util::query(" |
| 12 | SELECT |
| 13 | p.tsumego_id as tsumego_id, |
| 14 | a.latest_accepted_id AS latest_accepted_id, |
| 15 | p.id AS proposed_id, |
| 16 | p.user_id AS proposed_user_id, |
| 17 | user.name AS user_name, |
| 18 | set_connection.id AS set_connection_id, |
| 19 | set_connection.num AS num, |
| 20 | tsumego_status.status AS status, |
| 21 | CONCAT(`set`.title, ' ', `set`.title2) AS set_title |
| 22 | FROM sgf p |
| 23 | JOIN ( |
| 24 | SELECT tsumego_id, MAX(id) AS latest_accepted_id |
| 25 | FROM sgf |
| 26 | WHERE accepted = TRUE |
| 27 | GROUP BY tsumego_id |
| 28 | ) a ON a.tsumego_id = p.tsumego_id |
| 29 | JOIN set_connection ON set_connection.tsumego_id = p.tsumego_id |
| 30 | JOIN user ON p.user_id=user.id |
| 31 | JOIN `set` ON `set`.id = set_connection.set_id |
| 32 | LEFT JOIN tsumego_status ON tsumego_status.user_id = ? AND tsumego_status.tsumego_id = p.tsumego_id |
| 33 | WHERE p.accepted = FALSE |
| 34 | LIMIT " . self::$PAGE_SIZE . " |
| 35 | OFFSET " . $this->offset, [Auth::getUserID()]); |
| 36 | } |
| 37 | |
| 38 | public function renderItem(int $index, array $item): void |
| 39 | { |
| 40 | echo '<td class="adminpanel-table-text">' . $item['user_name'] . ' made a proposal for <a class="adminpanel-link" href="/' |
| 41 | . $item['set_connection_id'] . '">' . $item['set_title'] . ' - ' . $item['num'] . '</a>:</td>'; |
| 42 | echo '<td>'; |
| 43 | echo '<a href="/editor/?sgfID=' . $item['latest_accepted_id'] . '">current</a> | |
| 44 | <a href="/editor/?sgfID=' . $item['proposed_id'] . '">proposal</a> | |
| 45 | <a href="/editor/?sgfID=' . $item['proposed_id'] . '&diffID=' . $item['latest_accepted_id'] . '">diff</a>'; |
| 46 | echo '</td>'; |
| 47 | echo '<td>'; |
| 48 | new TsumegoButton($item['tsumego_id'], $item['set_connection_id'], $item['num'], $item['status'])->render(); |
| 49 | echo '<td><a class="new-button-default2" href="/users/acceptSGFProposal/' |
| 50 | . $item['proposed_id'] . '" id="accept-' . $item['proposed_id'] . '">Accept</a> |
| 51 | <a class="new-button-default2" href="/users/rejectSGFProposal/' . $item['proposed_id'] . '" id="reject-' . $item['proposed_id'] . '">Reject</a></td>'; |
| 52 | } |
| 53 | } |