Mark QSOs as uploaded in batch to improve performance
这个提交包含在:
父节点
c1d2a98da8
当前提交
4877b32304
共有 2 个文件被更改,包括 22 次插入 和 13 次删除
|
|
@ -61,7 +61,7 @@ class Webadif extends CI_Controller {
|
||||||
$result = $this->logbook_model->push_qso_to_webadif($webadif_api_url, $webadif_api_key, $adif);
|
$result = $this->logbook_model->push_qso_to_webadif($webadif_api_url, $webadif_api_key, $adif);
|
||||||
|
|
||||||
if ($result) {
|
if ($result) {
|
||||||
$this->logbook_model->mark_webadif_qsos_sent($qso->COL_PRIMARY_KEY);
|
$this->logbook_model->mark_webadif_qsos_sent([$qso->COL_PRIMARY_KEY]);
|
||||||
$i++;
|
$i++;
|
||||||
} else {
|
} else {
|
||||||
$errorMessage = 'QO-100 Dx Club upload failed for qso: Call: ' . $qso->COL_CALL . ' Band: ' . $qso->COL_BAND . ' Mode: ' . $qso->COL_MODE . ' Time: ' . $qso->COL_TIME_ON;
|
$errorMessage = 'QO-100 Dx Club upload failed for qso: Call: ' . $qso->COL_CALL . ' Band: ' . $qso->COL_BAND . ' Mode: ' . $qso->COL_MODE . ' Time: ' . $qso->COL_TIME_ON;
|
||||||
|
|
@ -149,8 +149,15 @@ class Webadif extends CI_Controller {
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($data['qsos']!==null) {
|
if ($data['qsos']!==null) {
|
||||||
|
$qsoIDs=[];
|
||||||
foreach ($data['qsos']->result() as $qso) {
|
foreach ($data['qsos']->result() as $qso) {
|
||||||
$this->logbook_model->mark_webadif_qsos_sent($qso->COL_PRIMARY_KEY);
|
$qsoIDs[]=$qso->COL_PRIMARY_KEY;
|
||||||
|
}
|
||||||
|
$batchSize = 500;
|
||||||
|
while ($qsoIDs !== []) {
|
||||||
|
$slice = array_slice($qsoIDs, 0, $batchSize);
|
||||||
|
$qsoIDs = array_slice($qsoIDs, $batchSize);
|
||||||
|
$this->logbook_model->mark_webadif_qsos_sent($slice);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -497,7 +497,7 @@ class Logbook_model extends CI_Model {
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($result) {
|
if ($result) {
|
||||||
$this->mark_webadif_qsos_sent($last_id);
|
$this->mark_webadif_qsos_sent([$last_id]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -632,17 +632,19 @@ class Logbook_model extends CI_Model {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Function marks QSOs as uploaded to WebADIF.
|
* Function marks QSOs as uploaded to WebADIF.
|
||||||
* $primarykey is the unique id for that QSO in the logbook
|
* $qsoIDs is an arroy of unique id for the QSOs in the logbook
|
||||||
*/
|
*/
|
||||||
function mark_webadif_qsos_sent($primarykey)
|
function mark_webadif_qsos_sent(array $qsoIDs)
|
||||||
{
|
{
|
||||||
$data = array(
|
$data = [];
|
||||||
'upload_date' => date("Y-m-d H:i:s", strtotime("now")),
|
$now = date("Y-m-d H:i:s", strtotime("now"));
|
||||||
'qso_id' => $primarykey,
|
foreach ($qsoIDs as $qsoID) {
|
||||||
);
|
$data[] = [
|
||||||
|
'upload_date' => $now,
|
||||||
$this->db->insert('webadif', $data);
|
'qso_id' => $qsoID,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
$this->db->insert_batch('webadif', $data);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1278,7 +1280,7 @@ class Logbook_model extends CI_Model {
|
||||||
/*
|
/*
|
||||||
* Function returns the QSOs from the logbook, which have not been either marked as uploaded to webADIF
|
* Function returns the QSOs from the logbook, which have not been either marked as uploaded to webADIF
|
||||||
*/
|
*/
|
||||||
function get_webadif_qsos($station_id,$from, $to){
|
function get_webadif_qsos($station_id,$from = null, $to = null){
|
||||||
$sql = "
|
$sql = "
|
||||||
SELECT qsos.*, station_profile.*
|
SELECT qsos.*, station_profile.*
|
||||||
FROM %s qsos
|
FROM %s qsos
|
||||||
|
|
|
||||||
正在加载…
在新工单中引用