Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
 * suicides & sus suicides
  • Loading branch information
a-sync committed Mar 24, 2024
1 parent 82c1119 commit 4a768b2
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 5 deletions.
7 changes: 5 additions & 2 deletions application/controllers/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public function fix_data($tab = 'missing')
$ops = $this->additional_data->get_ops_to_fix_data(true);
} elseif ($tab === 'unverified') {
$ops = $this->additional_data->get_ops_to_fix_data(false);
} else { // missing
} else { // sus
$ops = $this->additional_data->get_ops_to_fix_data(false, $op_ids_with_resolved_cmd);
}

Expand Down Expand Up @@ -410,6 +410,7 @@ public function events($op_id = null)
$entity_id = false;
$player_id = false;
$player = false;
$op_sus_suicides = [];
if (filter_var($op_id, FILTER_VALIDATE_INT) || filter_var($op_id, FILTER_VALIDATE_INT) === 0) {
$op = $this->operations->get_by_id($op_id);

Expand All @@ -434,6 +435,7 @@ public function events($op_id = null)
}

$op_events = $this->operations->get_events_by_id($op['id'], $entity_id, $player_id);
$op_sus_suicides = $this->additional_data->get_op_sus_suicides($op['id']);

$op_entities = $this->additional_data->get_op_entities($op['id']);
} else {
Expand All @@ -457,7 +459,8 @@ public function events($op_id = null)
'op_commanders' => $op_commanders,
'op_entities' => $op_entities,
'entity_id' => $entity_id,
'player' => $player
'player' => $player,
'op_sus_suicides' => $op_sus_suicides
]);

$this->_foot();
Expand Down
54 changes: 52 additions & 2 deletions application/models/Additional_data.php
Original file line number Diff line number Diff line change
Expand Up @@ -602,10 +602,43 @@ public function get_ops_to_fix_data($verified = false, $op_ids_with_unambiguous_
'operations.end_message',
'(SELECT COUNT(DISTINCT ents.side) FROM entities AS ents WHERE ents.operation_id = operations.id AND ents.is_player = 1) AS sides_total',
'IFNULL(dupe_deaths.multi_death_players_count, 0) AS multi_death_players_count',
'IFNULL(dupe_deaths.extra_deaths_count, 0) AS extra_deaths_count'
'IFNULL(dupe_deaths.extra_deaths_count, 0) AS extra_deaths_count',
"(SELECT COUNT(evs.id) FROM events AS evs INNER JOIN entities AS ents ON evs.attacker_aid = ents.aid AND ents.is_player = 1 WHERE evs.operation_id = operations.id AND evs.attacker_id = evs.victim_id AND evs.event = 'killed') AS suicides_total",
'IFNULL(sus_suicides.sus_suicides_count, 0) AS sus_suicides_count'
])
->from('operations')
->join('( SELECT player_deaths.id, COUNT(player_deaths.player_id) AS multi_death_players_count, SUM(player_deaths.extra_deaths) AS extra_deaths_count FROM ( SELECT o.id, e.player_id, SUM(e.deaths) - 1 AS extra_deaths FROM operations AS o INNER JOIN entities AS e ON o.id = e.operation_id AND e.player_id != 0 GROUP BY o.id, e.player_id HAVING SUM(e.deaths) > 1 ) AS player_deaths GROUP BY player_deaths.id ) AS dupe_deaths', 'dupe_deaths.id = operations.id', 'LEFT')
->join("(
SELECT
player_deaths.id,
COUNT(player_deaths.player_id) AS multi_death_players_count,
SUM(player_deaths.extra_deaths) AS extra_deaths_count
FROM (
SELECT o.id, e.player_id, SUM(e.deaths) - 1 AS extra_deaths
FROM operations AS o
INNER JOIN entities AS e ON o.id = e.operation_id AND e.player_id != 0
GROUP BY o.id, e.player_id
HAVING SUM(e.deaths) > 1
) AS player_deaths
GROUP BY player_deaths.id
) AS dupe_deaths",
'dupe_deaths.id = operations.id', 'LEFT')
->join("(
SELECT sus_suicide_events.operation_id, COUNT(sus_suicide_events.operation_id) AS sus_suicides_count
FROM (
SELECT e.operation_id, e.victim_aid
FROM events AS e
INNER JOIN entities AS victim ON victim.aid = e.victim_aid
LEFT JOIN (
SELECT ee.operation_id, ee.victim_id, frame
FROM events AS ee
WHERE ee.victim_id = ee.attacker_id AND ee.victim_id IS NOT NULL AND ee.event = 'hit'
GROUP BY ee.operation_id, ee.victim_id
) AS hits ON hits.operation_id = e.operation_id AND hits.victim_id = e.victim_id AND hits.frame = e.frame
WHERE e.victim_aid = e.attacker_aid AND hits.victim_id IS NULL AND victim.is_player = 1 AND e.event = 'killed'
) AS sus_suicide_events
GROUP BY sus_suicide_events.operation_id
) AS sus_suicides",
'sus_suicides.operation_id = operations.id', 'LEFT')
->where('operations.event !=', '')
->where('IFNULL(operations.verified, 0) =', $verified ? 1 : 0)
->order_by('operations.id DESC');
Expand All @@ -617,6 +650,7 @@ public function get_ops_to_fix_data($verified = false, $op_ids_with_unambiguous_
->or_where('operations.end_winner', '')
->or_where_not_in('operations.id', $op_ids_with_unambiguous_cmd)
->or_where('multi_death_players_count >', 0)
->or_where('sus_suicides_count >', 0)
->group_end();
}

Expand All @@ -625,6 +659,22 @@ public function get_ops_to_fix_data($verified = false, $op_ids_with_unambiguous_
->result_array();
}

public function get_op_sus_suicides($id)
{
$this->db->select('e.id')
->from('events AS e')
->join('entities AS victim', 'victim.aid = e.victim_aid')
->join("(SELECT ee.operation_id, ee.victim_id, frame
FROM events AS ee
WHERE ee.victim_id = ee.attacker_id AND ee.victim_id IS NOT NULL AND ee.event = 'hit'
GROUP BY ee.operation_id, ee.victim_id
) AS hits", 'hits.operation_id = e.operation_id AND hits.victim_id = e.victim_id AND hits.frame = e.frame', 'LEFT')
->where("e.victim_aid = e.attacker_aid AND hits.victim_id IS NULL AND victim.is_player = 1 AND e.event = 'killed'")
->where('e.operation_id', $id);

return array_column($this->db->get()->result_array(), 'id');
}

public function get_op_sides($id)
{
$this->db
Expand Down
8 changes: 7 additions & 1 deletion application/views/admin/events.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,13 @@
}

$event = html_escape($i['event']);
if ($i['event'] === 'connected' || $i['event'] === 'disconnected') {
if ($i['event'] === 'killed' && $i['victim_player_id'] !== null && $i['victim_id'] === $i['attacker_id']) {
if (in_array($i['id'], $op_sus_suicides)) {
$event .= ' ' . $warn_icon;
} else {
$event .= ' ' . $flaky_icon;
}
} elseif ($i['event'] === 'connected' || $i['event'] === 'disconnected') {
$event = html_escape($i['data']) . ' ' . $event;
} elseif ($i['event'] === 'captured') {
$d = json_decode($i['data']);
Expand Down
11 changes: 11 additions & 0 deletions application/views/admin/fix-data.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
<th class="mdc-data-table__header-cell" role="columnheader" scope="col" aria-sort="none" data-column-id="winner" title="End message">Winner</th>
<th class="mdc-data-table__header-cell" role="columnheader" scope="col" aria-sort="none" data-column-id="commanders">Commanders</th>
<th class="mdc-data-table__header-cell mdc-data-table__header-cell--numeric" role="columnheader" scope="col" aria-sort="none" data-column-id="multi_death_players__extra_deaths" title="Players with more then one death / Additional deaths">⛼👻</th>
<th class="mdc-data-table__header-cell mdc-data-table__header-cell--numeric" role="columnheader" scope="col" aria-sort="none" data-column-id="suicides__sus_suicides" title="Suicides / Sus suicides">💀☠</th>
</tr>
</thead>
<tbody class="mdc-data-table__content">
Expand Down Expand Up @@ -170,6 +171,16 @@
}
?>
</td>
<td class="mdc-data-table__cell mdc-data-table__cell--numeric">
<?php
if ($i['suicides_total'] > 0) {
echo html_escape($i['suicides_total']) . ' / ' . html_escape($i['sus_suicides_count']);
if ($i['sus_suicides_count'] > 0) {
echo' ' . $warn_icon;
}
}
?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
Expand Down

0 comments on commit 4a768b2

Please sign in to comment.