<commit_before>ValidationService =
    class ValidationService {


        /**
         * @memberOf ValidationService
         * @summary Add a new comment and update validation status of a given task. Does't do any security check as we can basically reach every state from every state
         * @locus Anywhere
         * @param taskId
         * @param validationStateAsked
         * @param validationType
         * @param comment
         */
        static updateValidation(taskId, validationStateAsked, validationType, comment) {
            var task = Tasks.findOne(taskId);
            var validationState = task[validationType];

            var now = new Date();
            validationState.comments.push({
                author: Users.findOne(Meteor.userId).name,
                content: comment,
                creationDate: now,
                stateBefore: validationState.currentState,
                stateAfter: validationStateAsked
            });
            validationState.currentState = validationStateAsked;
            validationState.lastUpdateDate = now;


            switch (validationType){
                case ValidationTypeUrl["time-slot"]:
                    Tasks.update({_id: task._id}, {$set: {timeSlotValidation: validationState}});
                    break;
                case ValidationTypeUrl["access-pass"]:
                    Tasks.update({_id: task._id}, {$set: {accessPassValidation: validationState}});
                    break;
                case ValidationTypeUrl["equipment"]:
                    Tasks.update({_id: task._id}, {$set: {equipmentValidation: validationState}});
                    break;
            }

        }

        static isUpdateAllowed(state) {
            if (state === ValidationState.OPEN || state === ValidationState.REFUSED)
                return true;
            return false
        }

    }<commit_msg>[RPI] #139 : first comments in array is the newest<commit_after>ValidationService =
    class ValidationService {


        /**
         * @memberOf ValidationService
         * @summary Add a new comment and update validation status of a given task. Does't do any security check as we can basically reach every state from every state
         * @locus Anywhere
         * @param taskId
         * @param validationStateAsked
         * @param validationType
         * @param comment
         */
        static updateValidation(taskId, validationStateAsked, validationType, comment) {
            var task = Tasks.findOne(taskId);
            var validationState = task[validationType];

            var now = new Date();
            validationState.comments.unshift({
                author: Users.findOne(Meteor.userId).name,
                content: comment,
                creationDate: now,
                stateBefore: validationState.currentState,
                stateAfter: validationStateAsked
            });
            validationState.currentState = validationStateAsked;
            validationState.lastUpdateDate = now;


            switch (validationType){
                case ValidationTypeUrl["time-slot"]:
                    Tasks.update({_id: task._id}, {$set: {timeSlotValidation: validationState}});
                    break;
                case ValidationTypeUrl["access-pass"]:
                    Tasks.update({_id: task._id}, {$set: {accessPassValidation: validationState}});
                    break;
                case ValidationTypeUrl["equipment"]:
                    Tasks.update({_id: task._id}, {$set: {equipmentValidation: validationState}});
                    break;
            }

        }

        static isUpdateAllowed(state) {
            if (state === ValidationState.OPEN || state === ValidationState.REFUSED)
                return true;
            return false
        }

    }
{'fraction_non_alphanumeric': 0.08663883089770355, 'fraction_numerical': 0.0007828810020876827, 'mean_word_length': 1.793731778425656, 'pattern_counts': {'":': 0, '<': 3, '<?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': '3424935', 'n_tokens_mistral': 937, 'n_tokens_neox': 846, 'n_words': 228}