first commit
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
$job_name ='parsedemail_item_fix_address';
|
||||
echo "[" . date("Y-m-d H:i:s") . "] ".$job_name." job is starting.\n";
|
||||
|
||||
require 'common/utils.php';
|
||||
require 'common/config.php';
|
||||
require 'common/address_city.php';
|
||||
require 'common/parser.php';
|
||||
require 'common/Geocode.php';
|
||||
|
||||
$total = $success = $failed = 0;
|
||||
|
||||
$q = "SELECT id, trackedemail_item_id
|
||||
FROM parsedemail_item_payment WHERE member_id is null;";
|
||||
$r = pg_query($readOnlyReplicaConn, $q);
|
||||
while ($f = pg_fetch_assoc($r)) {
|
||||
$total++;
|
||||
$id = $f['id'];
|
||||
$email_id = $f['trackedemail_item_id'];
|
||||
if (!empty($email_id)) {
|
||||
$member_id = getTrackedEmail($email_id);
|
||||
if ($member_id) {
|
||||
updateParsedPayment($id, $member_id);
|
||||
$success++;
|
||||
}
|
||||
} else {
|
||||
$failed++;
|
||||
}
|
||||
}
|
||||
|
||||
echo "Total: " . $total . ".\n";
|
||||
echo "Success: : " . $success . ".\n";
|
||||
echo "Failed: : " . $failed . ".\n";
|
||||
|
||||
|
||||
echo "[" . date("Y-m-d H:i:s") . "] ".$job_name." job complete.\n";
|
||||
|
||||
function getTrackedEmail($id)
|
||||
{
|
||||
global $readOnlyReplicaConn;
|
||||
$q = "SELECT member_id FROM trackedemail_item WHERE id = " . $id . "";
|
||||
$r = pg_query($readOnlyReplicaConn, $q);
|
||||
if ($r && pg_num_rows($r) && $f = pg_fetch_assoc($r)) {
|
||||
return $f['member_id'];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function updateParsedPayment($id, $member_id)
|
||||
{
|
||||
global $conn;
|
||||
$q = "UPDATE parsedemail_item_payment SET member_id='" . $member_id . "' WHERE id = " . $id . "";
|
||||
$r = pg_query($conn, $q);
|
||||
if ($r && pg_num_rows($r) && $f = pg_fetch_assoc($r)) {
|
||||
return [$f, null];
|
||||
}
|
||||
return [null, pg_last_error($conn)];
|
||||
}
|
||||
Reference in New Issue
Block a user