<commit_before>import utils from './utils';

export default {
    calculateGravity: function (recipe) {
        var og, fg;
        var attenuation = recipe.yeast.attenuation;
        var p = pointsPerGallon(recipe.fermentables, recipe.batchSize, recipe.efficiency);

        og = p / 1000 + 1;

        // FG
        if (recipe.attenuation <= 0) {
            attenuation = 75;
        }

        fg = 1 + ((100 - attenuation) / 100) * (og - 1);

        return {
            og: og,
            fg: fg
        };
    },
    calculateAbv: function (grav) {
        return utils.round((grav.og - grav.fg) * (125 * 1.05));
    }
};

function pointsPerGallon (fermentables, batchSize, efficiency) {
    var batchSizeGallons = utils.litersToGallons(batchSize);
    return fermentables.reduce(function (acc, fermentable) {
        var lbs = utils.kgsToLbs(fermentable.kgs);
        if (mashable(fermentable)) { // Efficiency counts only for mashable fermentables
            acc += ((fermentable.ppg - 1) * 1000 * lbs * (efficiency / 100)) / batchSizeGallons;
        } else {
            acc += ((fermentable.ppg - 1) * 1000 * lbs) / batchSizeGallons;
        }
        return acc;
    }, 0);
}

function mashable (fermentable) {
    return fermentable.type === 'Grains';
}
<commit_msg>Fix property for attenuation<commit_after>import utils from './utils';

export default {
    calculateGravity: function (recipe) {
        var og, fg;
        var attenuation = recipe.yeast.attenuation;
        var p = pointsPerGallon(recipe.fermentables, recipe.batchSize, recipe.efficiency);

        og = p / 1000 + 1;

        // FG
        if (attenuation <= 0) {
            attenuation = 75;
        }

        fg = 1 + ((100 - attenuation) / 100) * (og - 1);

        return {
            og: og,
            fg: fg
        };
    },
    calculateAbv: function (grav) {
        return utils.round((grav.og - grav.fg) * (125 * 1.05));
    }
};

function pointsPerGallon (fermentables, batchSize, efficiency) {
    var batchSizeGallons = utils.litersToGallons(batchSize);
    return fermentables.reduce(function (acc, fermentable) {
        var lbs = utils.kgsToLbs(fermentable.kgs);
        if (mashable(fermentable)) { // Efficiency counts only for mashable fermentables
            acc += ((fermentable.ppg - 1) * 1000 * lbs * (efficiency / 100)) / batchSizeGallons;
        } else {
            acc += ((fermentable.ppg - 1) * 1000 * lbs) / batchSizeGallons;
        }
        return acc;
    }, 0);
}

function mashable (fermentable) {
    return fermentable.type === 'Grains';
}

{'fraction_non_alphanumeric': 0.12548562548562547, 'fraction_numerical': 0.027972027972027972, 'mean_word_length': 2.1287970838396113, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '567902', 'n_tokens_mistral': 917, 'n_tokens_neox': 800, 'n_words': 197}