<commit_before>import debug from "debug";
import React, { Component, PropTypes } from "react";
import { updateState } from "../../store";
import Day from "../day";

const log = debug("schedule:components:day-list");

const TIME_MARGIN = 60 * 5 * 1000; // Display started events for 5 mins
const MODE_FILTERED = "filtered";
const MODE_ALL = "all";

export class DayList extends Component {
    updateDayListState(props) {
        const { getState } = props;
        const state = getState();
        const { mode } = state.daylist || { mode: MODE_FILTERED };
        const { time: { today, now }, days, tracks, sessions } = state;

        this.setState({
            mode,
            days: days.filter(d => MODE_ALL === mode ? d : today <= d.date).
            map(d => {
                return {
                    ...d,
                    tracks: tracks.filter(t => t.day === d.id).
                        map(t => ({
                            ...t,
                            sessions: sessions.filter(s => s.track === t.id).filter(s => MODE_ALL === mode ? s : now <= s.start + TIME_MARGIN)
                        }))
                };
            })
        });
    }

    switchMode(mode) {
        updateState("daylist", { mode });
    }

    componentWillMount() {
        this.updateDayListState(this.props);
    }

    componentWillReceiveProps(newProps) {
        this.updateDayListState(newProps);
    }

    render() {
        const { days, mode } = this.state;

        return (
            <div className="daylist">
                <div className="daylist__mode-switcher">
                    <a href="#" onClick={e => (e.preventDefault(), this.switchMode(MODE_ALL))}
                        className={MODE_ALL === mode && "active"}>All</a>
                    {" | "}
                    <a href="#" onClick={e => (e.preventDefault(), this.switchMode(MODE_FILTERED))} className={MODE_FILTERED === mode && "active"}>Upcoming</a>
                </div>

                {
                    days.map(d => {
                        return (
                            <div className="daylist__day">
                                <Day key={Number(d.date)} {...d} />
                            </div>
                        );
                    })
                }
            </div>
        );
    }
}

DayList.propTypes = {
    getState: PropTypes.func.isRequired
};

export default DayList;
<commit_msg>Fix filter out empty tracks from sessions list<commit_after>import debug from "debug";
import React, { Component, PropTypes } from "react";
import { updateState } from "../../store";
import Day from "../day";

const log = debug("schedule:components:day-list");

const TIME_MARGIN = 60 * 5 * 1000; // Display started events for 5 mins
const MODE_FILTERED = "filtered";
const MODE_ALL = "all";

export class DayList extends Component {
    updateDayListState(props) {
        const { getState } = props;
        const state = getState();
        const { mode } = state.daylist || { mode: MODE_FILTERED };
        const { time: { today, now }, days, tracks, sessions } = state;

        this.setState({
            mode,
            days: days.filter(d => MODE_ALL === mode ? d : today <= d.date).
            map(d => {
                return {
                    ...d,
                    tracks: tracks.
                        filter(t => t.day === d.id).
                        map(t => ({
                            ...t,
                            sessions: sessions.
                                filter(s => s.track === t.id).
                                filter(s => MODE_ALL === mode ? s : now <= s.start + TIME_MARGIN)
                        })).
                        filter(t => 0 < t.sessions.length)
                };
            })
        });
    }

    switchMode(mode) {
        updateState("daylist", { mode });
    }

    componentWillMount() {
        this.updateDayListState(this.props);
    }

    componentWillReceiveProps(newProps) {
        this.updateDayListState(newProps);
    }

    render() {
        const { days, mode } = this.state;

        return (
            <div className="daylist">
                <div className="daylist__mode-switcher">
                    <a href="#" onClick={e => (e.preventDefault(), this.switchMode(MODE_ALL))}
                        className={MODE_ALL === mode && "active"}>All</a>
                    {" | "}
                    <a href="#" onClick={e => (e.preventDefault(), this.switchMode(MODE_FILTERED))} className={MODE_FILTERED === mode && "active"}>Upcoming</a>
                </div>

                {
                    days.map(d => {
                        return (
                            <div className="daylist__day">
                                <Day key={Number(d.date)} {...d} />
                            </div>
                        );
                    })
                }
            </div>
        );
    }
}

DayList.propTypes = {
    getState: PropTypes.func.isRequired
};

export default DayList;

{'fraction_non_alphanumeric': 0.13810842896715472, 'fraction_numerical': 0.0033636723387415906, 'mean_word_length': 1.3544480670703307, 'pattern_counts': {'":': 0, '<': 30, '<?xml version=': 0, '>': 44, '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': '4211854', 'n_tokens_mistral': 1394, 'n_tokens_neox': 1325, 'n_words': 293}