Try catch on get jobs
This commit is contained in:
@@ -65,56 +65,60 @@ class WrenchJobs extends BaseController
|
|||||||
$in = json_decode($raw_json, true);
|
$in = json_decode($raw_json, true);
|
||||||
$in["action"] = -1; // bad number - we dont want formating WRENCHBOARD_ACCOUNT_JOBLIST; dont send this line , the formater will be confused
|
$in["action"] = -1; // bad number - we dont want formating WRENCHBOARD_ACCOUNT_JOBLIST; dont send this line , the formater will be confused
|
||||||
$out=[];
|
$out=[];
|
||||||
//$endpoint = "JOB_DATA-". $in["uid"];
|
|
||||||
$endpoint = "MARKET_JOB_DATA"; // All jobs Data
|
$endpoint = "MARKET_JOB_DATA"; // All jobs Data
|
||||||
|
log_message('critical', "ENTER ***** ***** WrenchJobs::getJobsData IN ");
|
||||||
|
try {
|
||||||
|
|
||||||
$out = $this->getCache($endpoint);
|
$out = $this->getCache($endpoint);
|
||||||
$countItem = 0;
|
$countItem = 0;
|
||||||
if( is_array($out)){
|
if( is_array($out)){
|
||||||
$countItem = count($out);
|
$countItem = count($out);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $countItem == 0 ){
|
||||||
|
$local_url = "http://".$this->micro_service_net1.":3033/marketjobs";
|
||||||
|
$out = $this->APIcall('GET', $local_url, $in);
|
||||||
|
// dont cache junk
|
||||||
|
if ( is_array($out) && is_array($out["result_list"]) && count($out["result_list"]) > 0){
|
||||||
|
$this->saveCache($endpoint,$out,360);
|
||||||
|
}
|
||||||
|
$out['internal_return'] = 0; // just backwad comaptobility
|
||||||
|
log_message('critical', "***** ***** WrenchJobs::getJobsData Cache Done:::Ret ");
|
||||||
|
}
|
||||||
|
|
||||||
|
$endpointW = "WALLETS-COUNTRY-". str_replace('-','_', $in["uid"]);
|
||||||
|
// $endpointW = "USER_WALLET_COUNTRY-". $in["uid"];
|
||||||
|
$outW = $this->getCache($endpointW);
|
||||||
|
// I need your wallet country here
|
||||||
|
if ( !is_array($outW["result_list"])){
|
||||||
|
$local_urlW = "http://".$this->micro_service_net1.":3033/walletcountry";
|
||||||
|
$outW = $this->APIcall('GET', $local_urlW, $in);
|
||||||
|
if ( is_array($outW["result_list"]) && count($outW["result_list"]) > 0){
|
||||||
|
$this->saveCache($endpointW,$outW,15660);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$filter_job_list =[];
|
||||||
|
$wallet_country = $first_names = array_column($outW['result_list'], 'country');;
|
||||||
|
foreach ($out['result_list'] as $item) {
|
||||||
|
if ( in_array( $item['job_country'], $wallet_country) ){
|
||||||
|
log_message('critical', "***** ***** WrenchJobs::ITEM ". serialize($item));
|
||||||
|
$filter_job_list[] = $item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log_message('critical', "***** ***** WrenchJobs::JOB AFTER FILTER Ret ". serialize($filter_job_list));
|
||||||
|
|
||||||
|
$out['result_list'] = $filter_job_list;
|
||||||
|
|
||||||
|
// Fileter result_list to wallet country
|
||||||
|
$endpoint = "WRENCH_JOB_INTEREST_COUNT";
|
||||||
|
$int_list = $this->getCache($endpoint)["result_list"];
|
||||||
|
$out["interest_list"] = ( isset($int_list) && is_array($int_list) ) ? $int_list : [];
|
||||||
|
|
||||||
|
} catch (Exception $e) {
|
||||||
|
echo 'Caught exception: ', $e->getMessage(), "\n";
|
||||||
}
|
}
|
||||||
|
log_message('critical', "END ***** ***** WrenchJobs::getJobsData Ret ");
|
||||||
if ( $countItem == 0 ){
|
|
||||||
$local_url = "http://".$this->micro_service_net1.":3033/marketjobs";
|
|
||||||
$out = $this->APIcall('GET', $local_url, $in);
|
|
||||||
// dont cache junk
|
|
||||||
if ( is_array($out) && is_array($out["result_list"]) && count($out["result_list"]) > 0){
|
|
||||||
$this->saveCache($endpoint,$out,360);
|
|
||||||
}
|
|
||||||
$out['internal_return'] = 0; // just backwad comaptobility
|
|
||||||
log_message('critical', "***** ***** WrenchJobs::getJobsData Cache Done:::Ret ");
|
|
||||||
}
|
|
||||||
|
|
||||||
$endpointW = "WALLETS-COUNTRY-". str_replace('-','_', $in["uid"]);
|
|
||||||
// $endpointW = "USER_WALLET_COUNTRY-". $in["uid"];
|
|
||||||
$outW = $this->getCache($endpointW);
|
|
||||||
// I need your wallet country here
|
|
||||||
if ( !is_array($outW["result_list"])){
|
|
||||||
$local_urlW = "http://".$this->micro_service_net1.":3033/walletcountry";
|
|
||||||
$outW = $this->APIcall('GET', $local_urlW, $in);
|
|
||||||
if ( is_array($outW["result_list"]) && count($outW["result_list"]) > 0){
|
|
||||||
$this->saveCache($endpointW,$outW,15660);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$filter_job_list =[];
|
|
||||||
$wallet_country = $first_names = array_column($outW['result_list'], 'country');;
|
|
||||||
foreach ($out['result_list'] as $item) {
|
|
||||||
if ( in_array( $item['job_country'], $wallet_country) ){
|
|
||||||
log_message('critical', "***** ***** WrenchJobs::ITEM ". serialize($item));
|
|
||||||
$filter_job_list[] = $item;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
log_message('critical', "***** ***** WrenchJobs::JOB AFTER FILTER Ret ". serialize($filter_job_list));
|
|
||||||
|
|
||||||
$out['result_list'] = $filter_job_list;
|
|
||||||
|
|
||||||
// Fileter result_list to wallet country
|
|
||||||
$endpoint = "WRENCH_JOB_INTEREST_COUNT";
|
|
||||||
$int_list = $this->getCache($endpoint)["result_list"];
|
|
||||||
$out["interest_list"] = ( isset($int_list) && is_array($int_list) ) ? $int_list : [];
|
|
||||||
|
|
||||||
log_message('critical', "***** ***** WrenchJobs::getJobsData Ret ");
|
|
||||||
return $this->respond( $this->summaryReturnData($in,$out), 200);
|
return $this->respond( $this->summaryReturnData($in,$out), 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user