<commit_before>import { ActionItemsMailHandler } from './ActionItemsMailHandler'
import { Minutes } from './../minutes'
import { ActionItem } from './../actionitem'

export class FinalizeMailHandler {

    constructor(minute) {
        if (!minute) {
            throw new Meteor.Error('illegal-argument', 'Minute id or object required');
        }
        if (typeof minute === 'string') {   // we may have an ID here.
            minute = new Minutes(minute);
        }

        this._minute = minute;
    }

    sendMails() {
        this._sendActionItems();
        //todo: this._sendProtocol();
    }

    _sendActionItems() {
        // create map recipient->mailHandler and add all AIs to the
        // mail handler for this recipient
        let userMailHandlerMap = [];
        let actionItems = this._minute.getOpenActionItems();
        actionItems.forEach(item => {
            item.getResponsibleArray().forEach(recipient => {
                if (!userMailHandlerMap.hasOwnProperty(recipient)) {
                    userMailHandlerMap[recipient] = new ActionItemsMailHandler(recipient);
                }
                userMailHandlerMap[recipient].addActionItem(item);
            });
        });

        // iterate over all mail handler and send the mails
        Object.keys(userMailHandlerMap).forEach(key => {
            userMailHandlerMap[key].send();
        });
    }
}<commit_msg>Refactored last step to use es6 syntax<commit_after>import { ActionItemsMailHandler } from './ActionItemsMailHandler'
import { Minutes } from './../minutes'
import { ActionItem } from './../actionitem'

export class FinalizeMailHandler {

    constructor(minute) {
        if (!minute) {
            throw new Meteor.Error('illegal-argument', 'Minute id or object required');
        }
        if (typeof minute === 'string') {   // we may have an ID here.
            minute = new Minutes(minute);
        }

        this._minute = minute;
    }

    sendMails() {
        this._sendActionItems();
        //todo: this._sendProtocol();
    }

    _sendActionItems() {
        // create map recipient->mailHandler and add all AIs to the
        // mail handler for this recipient
        let userMailHandlerMap = new Map();
        let actionItems = this._minute.getOpenActionItems();
        actionItems.forEach(item => {
            item.getResponsibleArray().forEach(recipient => {
                if (!userMailHandlerMap.has(recipient)) {
                    userMailHandlerMap.set(recipient, new ActionItemsMailHandler(recipient));
                }
                userMailHandlerMap.get(recipient).addActionItem(item);
            });
        });

        // iterate over all mail handler and send the mails
        for(let mailHandler of userMailHandlerMap.values()) {
            mailHandler.send();
        }
    }
}
{'fraction_non_alphanumeric': 0.11154253441581362, 'fraction_numerical': 0.00035298270384751147, 'mean_word_length': 2.1142857142857143, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 10, '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': '4210258', 'n_tokens_mistral': 758, 'n_tokens_neox': 719, 'n_words': 179}