<commit_before>'use strict'
import Dispatcher from './../core/appDispatcher';
import {EventEmitter} from 'events';
import {COMBO_ADD_NEW,COMBO_CLEAR_LIST,ARTIST_REMOVE} from './../constants/appConstants';

let CHANGE_EVENT = 'change';

class CombosListStore extends EventEmitter {
    constructor(){
        super();
        this._list = [];
        this.dispatchToken = null;
        this._registerDispatcher();
    }

    _emmitChange() {
        this.emit(CHANGE_EVENT);
    }

    _registerDispatcher() {
        this.dispatchToken = Dispatcher.register((action) => {
            switch(action.type) {

                case COMBO_ADD_NEW: {
                    this._list.push( action.combo );
                    this._emmitChange();
                    break;
                }

                case COMBO_CLEAR_LIST: {
                    this._list = [];
                    this._emmitChange();
                    break;
                }

                case ARTIST_REMOVE: {
                    let filteredList = this._list.filter((combo) => {
                        return combo.artist.id != action.artist.id;
                    })
                    this._list = filteredList;
                    //this._emmitChange();
                    break;
                }

                default: {
                    break;
                }
            }
            return action;
        });
    }

    addChangeListener(callback) {
        this.on(CHANGE_EVENT, callback);
    }

    removeChangeListener(callback) {
        this.removeListener(CHANGE_EVENT, callback);
    }

    getList() {
        return this._list;
    }

    getDuration() {
        let time = 0;
        this._list.map((combo) => {
            time+= combo.tracks[0].duration_ms + combo.tracks[1].duration_ms;
        });
        return this.msToTime(time);
    }
    msToTime(duration) {
        let minutes = parseInt((duration/(1000*60))%60)
            , hours = parseInt((duration/(1000*60*60))%24);
        console.log(minutes);
        hours = (hours < 10) ? "0" + hours : hours;
        minutes = (minutes < 10) ? "0" + minutes : minutes;

        return hours + "h" + (hours > 1? 's' : 'r') + ' ' + minutes + "m";
    }

}

export default new CombosListStore();<commit_msg>add playlist header and calculate playlist duration<commit_after>'use strict'
import Dispatcher from './../core/appDispatcher';
import {EventEmitter} from 'events';
import {COMBO_ADD_NEW,COMBO_CLEAR_LIST,ARTIST_REMOVE} from './../constants/appConstants';

let CHANGE_EVENT = 'change';

class CombosListStore extends EventEmitter {
    constructor(){
        super();
        this._list = [];
        this.dispatchToken = null;
        this._registerDispatcher();
    }

    _emmitChange() {
        this.emit(CHANGE_EVENT);
    }

    _registerDispatcher() {
        this.dispatchToken = Dispatcher.register((action) => {
            switch(action.type) {

                case COMBO_ADD_NEW: {
                    this._list.push( action.combo );
                    this._emmitChange();
                    break;
                }

                case COMBO_CLEAR_LIST: {
                    this._list = [];
                    this._emmitChange();
                    break;
                }

                case ARTIST_REMOVE: {
                    let filteredList = this._list.filter((combo) => {
                        return combo.artist.id != action.artist.id;
                    })
                    this._list = filteredList;
                    //this._emmitChange();
                    break;
                }

                default: {
                    break;
                }
            }
            return action;
        });
    }

    addChangeListener(callback) {
        this.on(CHANGE_EVENT, callback);
    }

    removeChangeListener(callback) {
        this.removeListener(CHANGE_EVENT, callback);
    }

    getList() {
        return this._list;
    }

    getDuration() {
        let time = 0;
        this._list.map((combo) => {
            time+= combo.tracks[0].duration_ms + combo.tracks[1].duration_ms;
        });
        return this._msToTime(time);
    }

    _msToTime(duration) {
        let minutes = parseInt((duration/(1000*60))%60)
            , hours = parseInt((duration/(1000*60*60))%24);
        hours = (hours < 10) ? "0" + hours : hours;
        minutes = (minutes < 10) ? "0" + minutes : minutes;

        return hours + "h" + (hours > 1? 's' : 'r') + ' ' + minutes + "m";
    }

}

export default new CombosListStore();
{'fraction_non_alphanumeric': 0.12239526211888573, 'fraction_numerical': 0.012283395481465233, 'mean_word_length': 1.5027442371020856, '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': '3841552', 'n_tokens_mistral': 1354, 'n_tokens_neox': 1237, 'n_words': 226}