mirror of
https://codeberg.org/demostf/api.git
synced 2026-06-03 09:54:17 +02:00
sort chat by tick
This commit is contained in:
parent
5f9dd4fd4c
commit
e7298576ca
2 changed files with 7 additions and 1 deletions
|
|
@ -72,6 +72,11 @@ class Parser {
|
||||||
if (!isset($data['chat'])) {
|
if (!isset($data['chat'])) {
|
||||||
throw new Exception('Error while parsing demo, no chat field found');
|
throw new Exception('Error while parsing demo, no chat field found');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
usort($data['chat'], function ($a, $b) {
|
||||||
|
return $a['tick'] <=> $b['tick'];
|
||||||
|
});
|
||||||
|
|
||||||
foreach ($data['chat'] as $message) {
|
foreach ($data['chat'] as $message) {
|
||||||
if (isset($message['from'])) {
|
if (isset($message['from'])) {
|
||||||
$chat[] = new ChatMessage($message['from'],
|
$chat[] = new ChatMessage($message['from'],
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,8 @@ class ChatProvider extends BaseProvider {
|
||||||
$query->select('text', '"from"', 'time')
|
$query->select('text', '"from"', 'time')
|
||||||
->from('chat')
|
->from('chat')
|
||||||
->where($query->expr()->eq('demo_id', $query->createNamedParameter($demoId, PDO::PARAM_INT)))
|
->where($query->expr()->eq('demo_id', $query->createNamedParameter($demoId, PDO::PARAM_INT)))
|
||||||
->orderBy('time', 'ASC');
|
->orderBy('time', 'ASC')
|
||||||
|
->addOrderBy('id', 'ASC');
|
||||||
|
|
||||||
$result = $query->execute();
|
$result = $query->execute();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue