Latency Issue - Category?

Forum for users and developers of Bullhorn's Webservices API suite

Moderators: StaffingSupport, s.emmons, BullhornSupport

Post Reply
ltcomm
User
Posts: 2
Joined: Tue Dec 11, 2012 3:31 pm

Latency Issue - Category?

Post by ltcomm » Mon Dec 17, 2012 11:48 am

I have a php query that seems to be working, but takes a very long time for the page to load (sometimes 22+ seconds for less than 20 jobs). I am trying to present open jobs by category. I have been told that it might be due to a problem with my not using the getAssociationId operation for getting a category for each job. I have not been able to find a PHP example for this on the forum, nor do I know if this might be causing the delay.

<?php
$params =array(
'trace' => 1,
'soap_version' => SOAP_1_1
);
$BHClient = new SoapClient("https://api.bullhornstaffing.com/webservices-2.0/?wsdl", $params);
$username = "";
$password = "";
$apiKey = "";

$session_request = new stdClass();
$session_request->username = $username;
$session_request->password = $password;
$session_request->apiKey = $apiKey;
$API_session = $BHClient->startSession($session_request);
$API_currentSession = $API_session->return->session;

$query="isOpen=1 AND status='Accepting Candidates' AND isDeleted=0";
if(isset($_GET['category'])){
if($_GET['category']=="540301"){
$query=$query." AND (540301 in elements(categories) OR 540302 in elements(categories) OR 540303 in elements(categories))";
}else{
$query=$query." AND (".$_GET['category']." in elements(categories))";
}
}

$query_array = array(
'distinct' => false,
'entityName' => 'JobOrder',
'maxResults' => 20,
'where' => $query,
'parameters' => array()
);
$SOAP_query = new SoapVar($query_array, SOAP_ENC_OBJECT, "dtoQuery", "http://query.apiservice.bullhorn.com/");
$request_array = array(
'session' => $API_currentSession,
'query' => $SOAP_query
);
$SOAP_request = new SoapVar($request_array, SOAP_ENC_OBJECT, "query", "http://query.apiservice.bullhorn.com/");
try
{
$queryResult = $BHClient->query($SOAP_request);
$API_currentSession = $queryResult->return->session;
}
catch (SoapFault $fault)
{
echo $fault->faultstring . '<br />';
}

$findId_array = array();
$results_len=count($queryResult->return->ids);
//echo (gettype($queryResult->return->ids));
if ($results_len>=1){
if ($results_len>1){
foreach($queryResult->return->ids as $value){
$find_id = new SoapVar($value, XSD_INTEGER, "int", "http://www.w3.org/2001/XMLSchema");
$findId_array[] = $find_id;
}
}
if ($results_len==1){
$find_id = new SoapVar($queryResult->return->ids, XSD_INTEGER, "int", "http://www.w3.org/2001/XMLSchema");
$findId_array = array(new SoapVar(999999, XSD_INTEGER, "int", "http://www.w3.org/2001/XMLSchema"),$find_id);
}
$find_request = array(
'session' => $API_currentSession,
'entityName' => 'JobOrder',
'ids' => $findId_array
);

try
{
$findResult = $BHClient->findMultiple($find_request);
}
catch (SoapFault $fault)
{
echo $fault->faultstring . '<br />';
}
}
?>



<?php if (count($findResult->return->dtos)>=1){ ?>
<?php foreach($findResult->return->dtos as $value):?>
<?php if ($value->jobOrderID!=""){ ?>

<?php
$type=$value->employmentType;
if($type=="Contract"){
echo "C";
}else if($type=="Direct Hire"){
echo "P";
}else if($type=="Contract to Hire"){
echo "CP";
}
?>
<?php echo $value->title; ?><?php echo $value->jobOrderID; ?>"><?php echo $value->jobOrderID; ?><?php echo '<br/>';?>

<?php }?>
<?php endforeach?>
<?php }else{ ?>

<?php } ?>

s.emmons
User
Posts: 333
Joined: Wed Dec 31, 1969 8:00 pm

Re: Latency Issue - Category?

Post by s.emmons » Wed Dec 19, 2012 12:33 pm

Hi ltcomm,

Thank you for posting your question. I have spoken with the analyst who is working on the Support ticket your client has open with us and he informs me that there hasn't been any update on the ticket since our conversation last Friday. I had emailed you regarding my thoughts on the category portion and I am not sure if you've been able to find anything to that end.

However, I did get a chance to speak with another member of the team here and he let me know that it is actually common for the operations running directly against the database upon loading the job page on the website to be a bit slow. What he told me to recommend in this situation is storing them locally on your webserver. The code for your job page would then be performing those queries against your local storage and not to the live Bullhorn database, which will result in better load times.
Sam Emmons
Enterprise Team Lead
BULLHORN
US Support 617-478-9126

ltcomm
User
Posts: 2
Joined: Tue Dec 11, 2012 3:31 pm

Re: Latency Issue - Category?

Post by ltcomm » Wed Dec 19, 2012 3:08 pm

Thanks for the suggestion. While I did not have a PHP example of the getAssociationID for category, I did remove the category information completely and just did a query on the JobOrder entity. I got the same results from a time perspective. So your suggestion may be the way to go. I can certainly see how doing a local query would improve speed, but I am not clear on how that would work from getting real-time job listings. Are you suggesting that I create an SQL database that mirrors your jobOrder entity and just search that? How would one automate the process to keep the data current?

Thanks,
LTCOMM

s.emmons
User
Posts: 333
Joined: Wed Dec 31, 1969 8:00 pm

Re: Latency Issue - Category?

Post by s.emmons » Wed Dec 19, 2012 4:43 pm

Hi LTCOMM,

You can store the information locally in whatever way works for you, the important thing is the dependency on running the query against the live database for each search. As far as a timeframe, that depends somewhat on the wishes of your client. If they are OK with the page running against the live database, say every hour for example, and then caching those results for the rest of that hour, then that's one way. The best way to get real time results would be to set up an event subscription to listen for inserts, updates, and deletes made in the application on the JobOrder entity. The events that are generated will contain an entityID for the JobOrder, you can then have the updated data overwritten on the copy that is stored locally. That way you can have a process running to update your local database in as close to real time as possible while still being able to run the queries for the actual webpage against your local webserver instead of the live database.
Sam Emmons
Enterprise Team Lead
BULLHORN
US Support 617-478-9126

Post Reply