Skip to content

Commit

Permalink
#741 Исправил проблемы логирования истории звонков.
Browse files Browse the repository at this point in the history
  • Loading branch information
boffart committed Nov 12, 2024
1 parent 8e32cf3 commit eae7a01
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ private static function regMissedCall(array $data, int $tmpCdrCount): void
$data['start'] = date("Y-m-d H:i:s.v", $time);
$data['endtime'] = $data['end'];

InsertDataToDB::execute($data);
InsertDataToDB::execute($data, $data['agi_channel']);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ private static function fillNotAnsweredCdr(WorkerCallEvents $worker, array $data
'bind' => [
'linkedid' => $data['linkedid'],
'src_chan' => $data['TRANSFERERNAME'],
'dst_chan' => $data['dst_chan'],
'dst_chan' => empty($data['dst_chan'])?$data['agi_channel']:$data['dst_chan'],
],
];
/** @var CallDetailRecordsTmp $m_data */
Expand Down
24 changes: 14 additions & 10 deletions src/Core/Workers/Libs/WorkerCallEvents/InsertDataToDB.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,26 +36,30 @@ class InsertDataToDB
* Execute the insertion of data into the database.
*
* @param array $data The data to be inserted.
* @param string $channel Channel data, additional filter.
* @return void
*/
public static function execute($data): void
public static function execute($data, string $channel = ''): void
{
if (empty($data['UNIQUEID'])) {
SystemMessages::sysLogMsg(__FUNCTION__, 'UNIQUEID is empty ' . json_encode($data), LOG_DEBUG);
return;
}

$is_new = false;
$filter = [
"UNIQUEID=:id: AND linkedid=:linkedid:",
'bind' => [
'id' => $data['UNIQUEID'],
'linkedid' => $data['linkedid']
],
];
if($channel !== ''){
$filter[0].= " AND (src_chan = :chan: OR dst_chan = :chan: )";
$filter['bind']['chan'] = $channel;
}
/** @var CallDetailRecordsTmp $m_data */
$m_data = CallDetailRecordsTmp::findFirst(
[
"UNIQUEID=:id: AND linkedid=:linkedid:",
'bind' => [
'id' => $data['UNIQUEID'],
'linkedid' => $data['linkedid']
],
]
);
$m_data = CallDetailRecordsTmp::findFirst($filter);
if ($m_data === null) {
// Create a new call record.
$m_data = new CallDetailRecordsTmp();
Expand Down

0 comments on commit eae7a01

Please sign in to comment.