<commit_before><?php

define('REST_SERVER', 'http://rest.local');
define('REST_PORT', $_SERVER['SERVER_PORT']);
/**
 * Some recipes, and accessors.  
 */
class Recipes extends CI_Model {

	// Constructor
	public function __construct()
	{
		parent::__construct();
        $this->load->library(['curl', 'format', 'rest']);
	}

	// retrieve a single recipe
	public function get($key, $key2 = null)
	{
        $this->rest->initialize(array('server'=>REST_SERVER));
        $this->rest->option(CURLOPT_PORT, REST_PORT);
        return $this->rest->get('/recipes/item/id/' . $key);
        
        
        /*
        $sql = sprintf("SELECT * from RECIPES where ID = %d", $which);
        $query = $this->db->query($sql);
        $result = $query->result();
        $reset = reset($result);
        return $reset;
        */
	}

	// get the recipes, what more do you want from me
	public function getRecipes()
	{
        $this->rest->initialize(array('server' => REST_SERVER));
        $this->rest->option(CURLOPT_PORT, REST_PORT);
        $result = $this->rest->get('recipes');
        return $result;
        
        
        /*
        $sql = sprintf("SELECT * from RECIPES");
        $query = $this->db->query($sql);
		return $query->result();
        */
	}
    
    // get the ingredients (description) of a single recipe
    public function getIngredients($recipeID){
        $this->rest->initialize(array('server'=>REST_SERVER));
        $this->rest->option(CURLOPT_PORT, REST_PORT);
        return $this->rest->get('/recipes/item/description/' . $key);
        
        
        /*
		$sql = sprintf("SELECT supplies.name, amount from SUPPLIES inner join RECIPESUPPLIES on SUPPLIES.id = RECIPESUPPLIES.supplyID inner join RECIPES on RECIPESUPPLIES.recipeID = RECIPES.ID where recipeID = %d", $recipeID); 
        $query = $this->db->query($sql); 
        return $query->result();
        */
    }
    
    public function getIngredientAmounts($recipeID){
        $this->rest->initialize(array('server'=>REST_SERVER));
        $this->rest->option(CURLOPT_PORT, REST_PORT);
        return $this->rest->get('/recipes/item/amount/' . $key);
        
        /*
        $sql = sprintf("SELECT supplies.id, amount from SUPPLIES inner join RECIPESUPPLIES on SUPPLIES.id = RECIPESUPPLIES.supplyID inner join RECIPES on RECIPESUPPLIES.recipeID = RECIPES.ID where recipeID = %d", $recipeID); 
        $query = $this->db->query($sql); 
        return $query->result();
        */
    }
    
    public function createRecipe($recipe, $ingredients, $price){
        $names = ['id','name','description','price','picture','category'];
        $object = new StdClass;
        foreach ($names as $name)
            $object->$name = "";
        return $object;
        
        $retrievedrecipe = $this->rest->post('/recipes/item/recipe/' . $recipe['code'], $recipe);
        $retrievedingredients = $this->rest->post('/recipes/item/ingredients/' . $ingredients['code'], $ingredients);
        $retrievedprice = $this->rest->post('/recipes/item/price/' . $price['code'], $price);<commit_msg>frontend2<commit_after><?php

define('REST_SERVER', 'http://a2-backend.local/maintenance');
define('REST_PORT', $_SERVER['SERVER_PORT']);
/**
 * Some recipes, and accessors.  
 */
class Recipes extends CI_Model {

	// Constructor
	public function __construct()
	{
		parent::__construct();
        $this->load->library(['curl', 'format', 'rest']);
	}

	// retrieve a single recipe
	public function get($key)
	{
        $this->rest->initialize(array('server'=>REST_SERVER));
        $this->rest->option(CURLOPT_PORT, REST_PORT);
        echo 'test';
        return $this->rest->get('/recipes/item/id/' . $key);
        
        
        /*
        $sql = sprintf("SELECT * from RECIPES where ID = %d", $which);
        $query = $this->db->query($sql);
        $result = $query->result();
        $reset = reset($result);
        return $reset;
        */
	}

	// get the recipes, what more do you want from me
	public function getRecipes()
	{
        $this->rest->initialize(array('server' => REST_SERVER));
        $this->rest->option(CURLOPT_PORT, REST_PORT);
        $result = $this->rest->get('/recipes');
        return $result;
        
        
        /*
        $sql = sprintf("SELECT * from RECIPES");
        $query = $this->db->query($sql);
		return $query->result();
        */
	}
    
    // get the ingredients (description) of a single recipe
    public function getIngredients($recipeID){
        $this->rest->initialize(array('server'=>REST_SERVER));
        $this->rest->option(CURLOPT_PORT, REST_PORT);
        return $this->rest->get('/recipesupplies/id/' . $recipeID);
        
        
        /*
		$sql = sprintf("SELECT supplies.name, amount from SUPPLIES inner join RECIPESUPPLIES on SUPPLIES.id = RECIPESUPPLIES.supplyID inner join RECIPES on RECIPESUPPLIES.recipeID = RECIPES.ID where recipeID = %d", $recipeID); 
        $query = $this->db->query($sql); 
        return $query->result();
        */
    }
    
    public function getIngredientAmounts($recipeID){
        $this->rest->initialize(array('server'=>REST_SERVER));
        $this->rest->option(CURLOPT_PORT, REST_PORT);
        return $this->rest->get('/recipes/item/amount/' . $key);
        
        /*
        $sql = sprintf("SELECT supplies.id, amount from SUPPLIES inner join RECIPESUPPLIES on SUPPLIES.id = RECIPESUPPLIES.supplyID inner join RECIPES on RECIPESUPPLIES.recipeID = RECIPES.ID where recipeID = %d", $recipeID); 
        $query = $this->db->query($sql); 
        return $query->result();
        */
    }
    
    public function createRecipe($recipe, $ingredients, $price){
        $names = ['id','name','description','price','picture','category'];
        $object = new StdClass;
        foreach ($names as $name)
            $object->$name = "";
        return $object;
        
        $retrievedrecipe = $this->rest->post('/recipes/item/recipe/' . $recipe['code'], $recipe);
        $retrievedingredients = $this->rest->post('/recipes/item/ingredients/' . $ingredients['code'], $ingredients);
        $retrievedprice = $this->rest->post('/recipes/item/price/' . $price['code'], $price);
{'fraction_non_alphanumeric': 0.1694750486066105, 'fraction_numerical': 0.0004860661049902787, 'mean_word_length': 2.6787842669845054, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 101, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '901504', 'n_tokens_mistral': 1975, 'n_tokens_neox': 1912, 'n_words': 375}