<commit_before><?php namespace App\Api;

class Recipes extends Api
{

    public $custom_recipes = [];

    /**
     * Get a list of all available recipes
     *
     * @return mixed
     */
    public function getList()
    {
        return $this->json('https://api.guildwars2.com/v2/recipes');
    }

    /**
     * Setup the custom recipes
     * This file is based on a forum thread, but doesn't include the material promotions
     * https://forum-en.guildwars2.com/forum/community/api/Created-a-json-file-for-Mystic-Forge-recipes
     */
    public function getCustomRecipes()
    {

        $recipes = $this->json('https://raw.githubusercontent.com/queicherius/gw2-mystic-forge-recipes/master/recipes.json');
        $recipes = $this->cleanupRecipes($recipes);

        // Save in internal structure
        foreach ($recipes as $recipe) {
            $this->custom_recipes[$recipe['output_item_id']] = $recipe;
        }

    }

    private function cleanupRecipes($recipes)
    {

        foreach ($recipes as $key => $recipe) {

            // Currency items as output
            if ($recipe['output_item_id'] < 0) {
                unset($recipes[$key]);
            }

            // Currency items as ingredients
            foreach ($recipe['ingredients'] as $i => $ingredient) {
                if ($ingredient['item_id'] < 0) {
                    unset($recipe['ingredients'][$i]);
                }
            }

            if (count($recipe['ingredients']) == 0) {
                unset($recipes[$key]);
            }

            // Circular dependencies
            if (in_array($recipe['output_item_id'], array_pluck($recipe['ingredients'], 'item_id'))) {
                unset($recipes[$key]);
            }

            // Demotions (globs and vials)
            if ($recipe['output_item_id'] == 38023 && in_array(38024, array_pluck($recipe['ingredients'], 'item_id'))) {
                unset($recipes[$key]);
            }

            // Circular dependency (nougat / skulls)
            if (in_array($recipe['output_item_id'], [38014, 36060, 36061])) {
                unset($recipes[$key]);
            }

            // Circular dependency (tonics)
            if ($recipe['output_item_id'] >= 38115 && $recipe['output_item_id'] <= 38127) {
                unset($recipes[$key]);<commit_msg>Fixes for "0" item ids<commit_after><?php namespace App\Api;

class Recipes extends Api
{

    public $custom_recipes = [];

    /**
     * Get a list of all available recipes
     *
     * @return mixed
     */
    public function getList()
    {
        return $this->json('https://api.guildwars2.com/v2/recipes');
    }

    /**
     * Setup the custom recipes
     * This file is based on a forum thread, but doesn't include the material promotions
     * https://forum-en.guildwars2.com/forum/community/api/Created-a-json-file-for-Mystic-Forge-recipes
     */
    public function getCustomRecipes()
    {

        $recipes = $this->json('https://raw.githubusercontent.com/queicherius/gw2-mystic-forge-recipes/master/recipes.json');
        $recipes = $this->cleanupRecipes($recipes);

        // Save in internal structure
        foreach ($recipes as $recipe) {
            $this->custom_recipes[$recipe['output_item_id']] = $recipe;
        }

    }

    private function cleanupRecipes($recipes)
    {

        foreach ($recipes as $key => &$recipe) {

            // Currency items as output
            if ($recipe['output_item_id'] <= 0) {
                unset($recipes[$key]);
            }

            // Currency items as ingredients
            foreach ($recipe['ingredients'] as $i => $ingredient) {
                if ($ingredient['item_id'] <= 0) {
                    unset($recipe['ingredients'][$i]);
                }
            }

            $recipe['ingredients'] = array_values($recipe['ingredients']);
            if (count($recipe['ingredients']) == 0) {
                unset($recipes[$key]);
            }

            // Circular dependencies
            if (in_array($recipe['output_item_id'], array_pluck($recipe['ingredients'], 'item_id'))) {
                unset($recipes[$key]);
            }

            // Demotions (globs and vials)
            if ($recipe['output_item_id'] == 38023 && in_array(38024, array_pluck($recipe['ingredients'], 'item_id'))) {
                unset($recipes[$key]);
            }

            // Circular dependency (nougat / skulls)
            if (in_array($recipe['output_item_id'], [38014, 36060, 36061])) {
                unset($recipes[$key]);
            }

            // Circular dependency (tonics)
            if ($recipe['output_item_id'] >= 38115 && $recipe['output_item_id'] <= 38127) {
                unset($recipes[$key]);
{'fraction_non_alphanumeric': 0.146779303062302, 'fraction_numerical': 0.01795142555438226, 'mean_word_length': 1.9711417816813048, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 17, 'https://': 6, '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': '613858', 'n_tokens_mistral': 1513, 'n_tokens_neox': 1393, 'n_words': 263}