Merge pull request #2043 from hugosilvaparagramanet/feature/improve-mark-as-upload-process-for-qo100-dx-club-export
Mark QSOs as uploaded in batch to improve performance
这个提交包含在:
当前提交
d675941d1e
共有 2 个文件被更改,包括 21 次插入 和 12 次删除
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
正在加载…
在新工单中引用