<commit_before>/*
Calculate discount for selected half days (Monday and Saturday)
*/
var calculateDiscount = function (firstTimeAttender, days) {
    // Placeholder for first time discount amount
    var firstTimeDiscount;

    // Placeholder for number of discount days
    var numberOfDiscountDays;

    // Get an array of selected discount days
    if (days ) {
        var discountDays = days.filter(function(day) {
            return (day === "Monday" || day === "Saturday");
        });

        // Set number of days to length of selected discount days array
        numberOfDiscountDays = discountDays.length;
    } else {
        numberOfDays = 0;
    }
    // Set discount if registrant is first time attender, otherwise zero
    if (firstTimeAttender) {
        firstTimeDiscount = firstTimeAttenderDiscount;
    } else {
        firstTimeDiscount = 0;
    }

    // Calculate the daily discount
    var discountDaysTotalDiscount = numberOfDiscountDays * halfDayDiscountAmount;

    // Add discount days and first time discount values
    var calculatedDiscount =  discountDaysTotalDiscount + firstTimeDiscount;

    return calculatedDiscount;
};

/*
    * Calculate registration type based on
    *    Age,
    *    registration type,
    *    accommodations, and
    *    days
    */
calculateRegistrationPrice = function (registration) {
    var total = 0; // Used for total registration fee
    var dayFee; // Used for daily registration day price
    var accommodationsFee; // Used for accommodations price
    var calculatedDiscount; // Used for discount price

    if (registration.type === 'commuter') {
        // Check for required information
        if (registration.ageGroup && registration.days) {
            // retrieve the day fee from the prices list
            dayFee = prices[registration.ageGroup][registration.type];

            // set the number of days
            var numberOfDays = registration.days.length;

            // Calculate discount based on half days
            calculatedDiscount = calculateDiscount(registration.firstTimeAttender, registration.days);
            console.log(calculatedDiscount);

            //calculate the fee
            accommodationsFee = dayFee * numberOfDays;
            console.log(accommodationsFee);

            if (accommodationsFee > calculatedDiscount) {
                return accommodationsFee - calculatedDiscount;
            } else {
                return 0;
            }

        } else {
            // not enough detail
            return;
        }
    }

    // Daily fee calculation
    if (registration.type === 'daily') {
        // Check for required information
        if (registration.ageGroup && registration.days) {
            // retrieve the day fee from the prices list
            dayFee = prices[registration.ageGroup][registration.type][registration.accommodations];

            // set the number of days
            var numberOfDays = registration.days.length;

            // Calculate discount based on half days
            calculatedDiscount = calculateDiscount(registration.firstTimeAttender, registration.days);

            // calculate the fee
            accommodationsFee = dayFee * numberOfDays;

            if (accommodationsFee > calculatedDiscount) {
                return accommodationsFee - calculatedDiscount;
            } else {
                return 0;
            }

        } else {
            // not enough detail
            return;
        }
    }

    if (registration.type === 'weekly') {

        if (registration.ageGroup && registration.type && registration.accommodations) {
            var accommodationsFee = prices[registration.ageGroup][registration.type][registration.accommodations];

            var calculatedDiscount = calculateDiscount(registration.firstTimeAttender, registration.days);

            if (accommodationsFee > calculatedDiscount) {
                return accommodationsFee - calculatedDiscount;
            } else {
                return 0;
            }
        } else {
            // Not enough detail.
            return;
        }
    }

    // otherwise return nothing
    return;
};
<commit_msg>Added linens to overnight calculations. Cleanup.<commit_after>/*
Calculate discount for selected half days (Monday and Saturday)
*/
var calculateDiscount = function (firstTimeAttender, days) {
    // Placeholder for first time discount amount
    var firstTimeDiscount;

    // Placeholder for number of discount days
    var numberOfDiscountDays;

    // Get an array of selected discount days
    if (days ) {
        var discountDays = days.filter(function(day) {
            return (day === "Monday" || day === "Saturday");
        });

        // Set number of days to length of selected discount days array
        numberOfDiscountDays = discountDays.length;
    } else {
        numberOfDays = 0;
    }
    // Set discount if registrant is first time attender, otherwise zero
    if (firstTimeAttender) {
        firstTimeDiscount = firstTimeAttenderDiscount;
    } else {
        firstTimeDiscount = 0;
    }

    // Calculate the daily discount
    var discountDaysTotalDiscount = numberOfDiscountDays * halfDayDiscountAmount;

    // Add discount days and first time discount values
    var calculatedDiscount =  discountDaysTotalDiscount + firstTimeDiscount;

    return calculatedDiscount;
};

/*
    * Calculate registration type based on
    *    Age,
    *    registration type,
    *    accommodations, and
    *    days
    */
calculateRegistrationPrice = function (registration) {
    var total = 0; // Used for total registration fee
    var dayFee; // Used for daily registration day price
    var accommodationsFee; // Used for accommodations price
    var calculatedDiscount; // Used for discount price
    var linens; // used for overnight registrations

    if (registration.type === 'commuter') {
        // Check for required information
        if (registration.ageGroup && registration.days) {
            // retrieve the day fee from the prices list
            dayFee = prices[registration.ageGroup][registration.type];

            // set the number of days
            var numberOfDays = registration.days.length;

            // Calculate discount based on half days
            calculatedDiscount = calculateDiscount(registration.firstTimeAttender, registration.days);

            //calculate the fee
            accommodationsFee = dayFee * numberOfDays;

            if (accommodationsFee > calculatedDiscount) {
                return accommodationsFee - calculatedDiscount;
            } else {
                return 0;
            }

        } else {
            // not enough detail
            return;
        }
    }

    // Daily fee calculation
    if (registration.type === 'daily') {
        // Check for required information
        if (registration.ageGroup && registration.days) {
            // retrieve the day fee from the prices list
            dayFee = prices[registration.ageGroup][registration.type][registration.accommodations];

            // set the number of days
            var numberOfDays = registration.days.length;

            // Determine linens fee
            if (registration.linens) {
                linens = linensFee;
            } else {
                linens = 0;
            }

            // Calculate discount based on half days
            calculatedDiscount = calculateDiscount(registration.firstTimeAttender, registration.days);

            // calculate the fee
            accommodationsFee = (dayFee * numberOfDays) + linens;

            if (accommodationsFee > calculatedDiscount) {
                return accommodationsFee - calculatedDiscount;
            } else {
                return 0;
            }

        } else {
            // not enough detail
            return;
        }
    }

    if (registration.type === 'weekly') {

        if (registration.ageGroup && registration.type && registration.accommodations) {
            var accommodationsPrice = prices[registration.ageGroup][registration.type][registration.accommodations];

            var calculatedDiscount = calculateDiscount(registration.firstTimeAttender, registration.days);

            // Determine linens fee
            if (registration.linens) {
                linens = linensFee;
            } else {
                linens = 0;
            }

            // Determine full fee amount (accommodations + linens)
            accommodationsFee = accommodationsPrice + linens;

            if (accommodationsFee > calculatedDiscount) {
                return accommodationsFee - calculatedDiscount;
            } else {
                return 0;
            }
        } else {
            // Not enough detail.
            return;
        }
    }

    // otherwise return nothing
    return;
};

{'fraction_non_alphanumeric': 0.07552289429055964, 'fraction_numerical': 0.0015828151498021481, 'mean_word_length': 1.9935702199661591, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '1505284', 'n_tokens_mistral': 2250, 'n_tokens_neox': 2089, 'n_words': 631}