From 477f15a195c065eeb9ad77e4ef55a5020ba5c256 Mon Sep 17 00:00:00 2001 From: Joel Salisbury Date: Thu, 24 Jan 2019 12:57:37 -0500 Subject: [PATCH] rerank --- swap-api/src/routes.php | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/swap-api/src/routes.php b/swap-api/src/routes.php index cb9f564..efe92ea 100644 --- a/swap-api/src/routes.php +++ b/swap-api/src/routes.php @@ -27,6 +27,46 @@ return $response->getBody()->write(Food::all()->toJson()); }); +// $app->get('/reRankAllFoods', function($request, $response){ +// ini_set('max_execution_time', 300); +// $foods = Food::all(); + +// $nix_appID = "e2153d42"; +// $nix_appKey = "ccb97a64a7b7b1b8f7e64de881c9ee4b"; + + +// foreach($foods as $food) { +// $upc = $food->barcode; +// $catId = $food->category_id; +// $endpoint = "http://api.nutritionix.com/v1_1/item?upc=".$upc. +// "&appId=".$nix_appID. +// "&appKey=".$nix_appKey; + +// //echo $endpoint; +// $ch = curl_init($endpoint); +// curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); +// $res = curl_exec($ch); +// curl_close($ch); + +// $res = json_decode($res); + +// if (!isset($res->error_code)) { + +// $food->category()->associate($catId); + +// $scr = getScore($catId, array( +// "sodium" => $res->nf_sodium, +// "satfat" => $res->nf_saturated_fat, +// "sugars" => $res->nf_sugars +// )); + +// $food->rank()->associate($scr); + +// $food->save(); +// } +// } +// }); + $app->get('/pinfo/', function($request, $response) { return phpinfo(); });