/ lcrum
APIs Published
0
APIs Following
1
API Spotlight
0
Followed By
1
Users Following
1
This user has no published APIs
Users Following
1
Discussions
7
AllQuestionsAnswers
arrowNewest
a12Just to let you know in case it could help, we also have another function that it's generating big delays: searchRecipe_webknox_byId.txt() Here the code: https://drive.google.com/file/d/0B0JLtCxM0qkmUGVqTDRYVWJJNE0/edit?usp=sharing
Thu 7:453/7/14
a12Thank you so much David
Thu 7:453/7/14
a12Hello there, sorry for the delay in answer, but we where making an accurate debug of our code. We stil have problems, the avarage delay is 10 seconds, and it is a really big issue impacting seriously our service. We found out that the following function call is generating the delay, anytime: $searchResults_webknox= searchRecipe_webknox($queryString, $limitResults_webknox); I have shared with you the code of the function searchRecipe_webknox() https://drive.google.com/file/d/0B0JLtCxM0qkmTGFVTzNPN3VNYm8/edit?usp=sharing Could you please have a look? We may do something wrong? Please, we really need your expertice to fix this issue. Thank you in advance.
Thu 7:453/7/14
a12Hello there, sorry for the delay in answer, but we where making an accurate debug of our code. We stil have problems, the avarage delay is 10 seconds, and it is a really big issue impacting seriously our service. We found out that the following function call is generating the delay, anytime: $searchResults_webknox= searchRecipe_webknox($queryString, $limitResults_webknox); Following the function code, could you please have a look? We may do something wrong? We really need your expertice to fix this issue. function searchRecipe_webknox($queryIngredients, $limitOfResults){ require_once 'unirest-php-master/unirest-php-master/lib/Unirest.php'; require_once 'unirest-php-master/unirest-php-master/lib/Unirest/HttpResponse.php'; //echo "<br> CheckPoint 01 - LIB imported"; $api_search_url = "https://webknox-recipes.p.mashape.com/recipes/search?query="; $search_param_separator = "&"; //echo "<br> queryIngredients: " . $queryIngredients; // TO DO ?? $queryIngredients should be parsed somehow or it will be already tested and encoded ??? $search_param_query = $queryIngredients; // Filters - to be defined ******************************************************** /* $search_param_offset = "offset=0"; //$search_param_offset = ""; $search_param_number = "number=9"; */ $search_param_number = "number=" . $limitOfResults; /* $search_param_type = "type=main%20course"; //$search_param_type = ""; $search_param_cuisine = "cuisine=italian"; //$search_param_cuisine = ""; $search_param_diet = "diet=vegetarian"; //$search_param_diet = ""; $search_param_intolerances = "intolerances=egg"; //$search_param_intolerances = ""; $search_param_excludeIngredients = "excludeIngredients=coconut"; // $search_param_excludeIngredients = ""; */ // End of filters ***************************************************************** try { $search_string = $api_search_url . $search_param_query . //$search_param_separator . $search_param_offset . $search_param_separator . $search_param_number /* . $search_param_separator . $search_param_type . $search_param_separator . $search_param_cuisine . $search_param_separator . $search_param_diet . $search_param_separator . $search_param_intolerances . $search_param_separator . $search_param_excludeIngredients */ ; //echo "<br> CheckPoint 03 Search url -> " . $search_string; $searchResponse = Unirest::get( $search_string , array("X-Mashape-Authorization" => "30GIsAd66m2FYl0ivUKHr9cd2Bcrdzas") , null); if ($searchResponse == NULL) { //echo "<br> searchResponse is null !!!"; exit; } /*else { //echo "<br> searchResponse is NOT null !!!"; //echo "<br> CheckPoint-06 var_dump(searchResponse)"; //var_dump($searchResponse); }*/ //echo "<br> searchResponse exp. time: " . $searchResponse->{'expires'}; $resultObj = new Result(); $searchResponseTotalResults = (int)$searchResponse->{'totalResults'}; $searchResponseNumber = (int)$searchResponse->{'number'}; $resultObj->setTotResNum($searchResponseTotalResults); if($searchResponseTotalResults >= $searchResponseNumber){ $resultObj->setActResNum($searchResponseNumber); } else { $resultObj->setActResNum($searchResponseTotalResults); } $resultObj->setImgsUri($searchResponse->{'baseUri'}); if($resultObj->getActResNum() > 0) { foreach ($searchResponse->{'results'} as $recipe) { $recipeItem = new Recipe(); $recipeItem->setTitle($recipe->{'title'}); $recipeItem->setImgName($recipe->{'image'}); /* Test to retrieve more info */ $recipeId = $recipe->{'id'}; $recipeItem->setId($recipeId); $search_string_more_info = "https://webknox-recipes.p.mashape.com/recipes/" . $recipeId ."/information"; $moreInfo = Unirest::get( $search_string_more_info , array("X-Mashape-Authorization" => "30GIsAd66m2FYl0ivUKHr9cd2Bcrdzas") , null); if ($moreInfo == NULL) { } else { $recipeItem->setRecipeServings($moreInfo->{'servings'}); $recipeItem->setPrepMins($moreInfo->{'preparationMinutes'}); $recipeItem->setCookingMins($moreInfo->{'cookingMinutes'}); $recipeItem->setReadyMins($moreInfo->{'readyInMinutes'}); foreach ($moreInfo->{'extendedIngredients'} as $ingredient) { $aisle = $ingredient->{'aisle'}; if($aisle != "?") { $ingredientObj = new Ingredient(); $ingredientObj->setOriginalDesc($ingredient->{'originalString'}); $ingredientObj->setShortName($ingredient->{'name'}); $recipeItem->addIngredient($ingredientObj); } } $recipeItem->setSourceUrl($moreInfo->{'sourceUrl'}); } // end else $resultObj->addRecipe($recipeItem); } // end for each } //end if /*else { //echo "<br> NO RESULTS "; }*/ return $resultObj; } catch (Exception $e) { $error .= sprintf('<p>A service error occurred: <code>%s</code></p>', htmlspecialchars($e->getMessage())); echo $error; exit; } } ?>
Thu 7:453/7/14
a12The function is still too slow for us, but thank you so much for your support. I hope you could implement the other improvement you have in mind soon :) We will try to split the call using AJAX in orther to do the most on the server side.
Thu 7:453/7/14
a12So, to improve the performance so it is between 5 and 10 times faster now, did you modify my code? Or did you just make some modification by your side?
Thu 7:453/7/14
Showing 1-6 of 7 results

Install SDK for (Node.js)Unirest

OAuth2 Authentication
Client ID
Client Secret
OAuth2 Authentication