<commit_before>(function () {
    'use strict';

    var toFloat = function (value) {
        return Math.round(parseFloat(value) * 10) / 10;
    };

    angular.module('psadmin').service('PresentationService', function ($filter) {
        var that = this;
        this.getCompetition = function (event, id) {
            var result = $filter('entryOfId')(id, event.competitions);
            return result ? result : {};
        };

        this.getGroup = function (competition, id) {
            var result = $filter('entryOfId')(id, competition.groups);
            return result ? result : {};
        };

        this.getGroupParticipant = function (group, id) {
            var result = $filter('entryOfId')(id, group.participants);
            if (!result && group.sacrifice && group.sacrifice.id == id) {
                result = group.sacrifice;
            }
            return result ? result : null;
        };

        this.getParticipant = function (event, id) {
            if (!id) return {};
            var result = $filter('entryOfId')(id, event.participants);
            return result ? result : null;
        };

        this.sumScore = function (scores) {
            var total = 0;
            scores.forEach(function (score) {
                if (score.value && !score.ignored) {
                    total += toFloat(score.value);
                }
            });
            return Math.round(total * 10) / 10;
        };

        this.sumScoreSecond = function (scores) {
            var total = 0;
            scores.forEach(function (score) {
                if (score.value) {
                    total += toFloat(score.value);
                }
            });
            return Math.round(total * 10) / 10;
        };

        this.markIgnoredScores = function (scores) {
            var lowest = 99999, highest = -99999;

            scores.forEach(function (score) {
                if (score !== '') {
                    var value = toFloat(score.value);
                    if (value < lowest) lowest = value;
                    else if (value > highest) highest = value;
                }
                score.ignored = false;
            });

            if (scores.length >= 1) {
                if (lowest < 11) {
                    scores.filter(function (score) {
                        return toFloat(score.value) === lowest;
                    })[0].ignored = true;
                }
            }
            if (scores.length >= 2) {
                if (highest > -1) {
                    scores.filter(function (score) {
                        return toFloat(score.value) === highest && !score.ignored;
                    })[0].ignored = true;
                }
            }
        };

        var generateGroupResultList = function (groupParticipants, event) {
            if (!groupParticipants || !groupParticipants.length) return [];
            var result = groupParticipants
                .filter(function (groupParticipant) {
                    return groupParticipant.scores && groupParticipant.scores[0].value !== '';
                })
                .map(function (groupParticipant) {
                    var participant = that.getParticipant(event, groupParticipant.id);
                    return {
                        name: participant.name,
                        slam: participant.slam,
                        participantId: participant.id,
                        scores: groupParticipant.scores,
                        totalScore: groupParticipant.totalScore,
                        secondTotalScore: groupParticipant.secondTotalScore
                    };
                });<commit_msg>fix bug in calculation of min / max value<commit_after>(function () {
    'use strict';

    var toFloat = function (value) {
        return Math.round(parseFloat(value) * 10) / 10;
    };

    angular.module('psadmin').service('PresentationService', function ($filter) {
        var that = this;
        this.getCompetition = function (event, id) {
            var result = $filter('entryOfId')(id, event.competitions);
            return result ? result : {};
        };

        this.getGroup = function (competition, id) {
            var result = $filter('entryOfId')(id, competition.groups);
            return result ? result : {};
        };

        this.getGroupParticipant = function (group, id) {
            var result = $filter('entryOfId')(id, group.participants);
            if (!result && group.sacrifice && group.sacrifice.id == id) {
                result = group.sacrifice;
            }
            return result ? result : null;
        };

        this.getParticipant = function (event, id) {
            if (!id) return {};
            var result = $filter('entryOfId')(id, event.participants);
            return result ? result : null;
        };

        this.sumScore = function (scores) {
            var total = 0;
            scores.forEach(function (score) {
                if (score.value && !score.ignored) {
                    total += toFloat(score.value);
                }
            });
            return Math.round(total * 10) / 10;
        };

        this.sumScoreSecond = function (scores) {
            var total = 0;
            scores.forEach(function (score) {
                if (score.value) {
                    total += toFloat(score.value);
                }
            });
            return Math.round(total * 10) / 10;
        };

        this.markIgnoredScores = function (scores) {
            var lowest = 99999, highest = -99999;

            scores.forEach(function (score) {
                if (score !== '') {
                    var value = toFloat(score.value);
                    if (value < lowest) lowest = value;
                    if (value > highest) highest = value;
                }
                score.ignored = false;
            });

            if (scores.length >= 1) {
                if (lowest < 99999) {
                    scores.filter(function (score) {
                        return toFloat(score.value) === lowest;
                    })[0].ignored = true;
                }
            }
            if (scores.length >= 2) {
                if (highest > -99999) {
                    scores.filter(function (score) {
                        return toFloat(score.value) === highest && !score.ignored;
                    })[0].ignored = true;
                }
            }
        };

        var generateGroupResultList = function (groupParticipants, event) {
            if (!groupParticipants || !groupParticipants.length) return [];
            var result = groupParticipants
                .filter(function (groupParticipant) {
                    return groupParticipant.scores && groupParticipant.scores[0].value !== '';
                })
                .map(function (groupParticipant) {
                    var participant = that.getParticipant(event, groupParticipant.id);
                    return {
                        name: participant.name,
                        slam: participant.slam,
                        participantId: participant.id,
                        scores: groupParticipant.scores,
                        totalScore: groupParticipant.totalScore,
                        secondTotalScore: groupParticipant.secondTotalScore
                    };
                });
{'fraction_non_alphanumeric': 0.11163734776725305, 'fraction_numerical': 0.009607577807848443, 'mean_word_length': 1.3367056591843187, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, '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': '349312', 'n_tokens_mistral': 1963, 'n_tokens_neox': 1743, 'n_words': 400}