<commit_before>import debug from "debug";
import React, { Component } from "react";
import Track from "../track";

const log = debug("schedule:components:happening-now");

export class HappeningNow extends Component {
    updateCurrentSessions(props) {
        const { getState } = props;
        const { current, tracks, sessions } = getState();

        this.setState({
            sessions: current.sessions.
                map(id => sessions[id]).
                reduce((a, s) => null == a.find(ss => s.track === ss.track) ? [...a, s] : a, []).
                slice(0, 3).
                map(s => ({ ...tracks[s.track], sessions: [s] }))
        });
    }

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

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

    render() {
        const { sessions } = this.state;

        return (
            <div className="current-sessions">
                {
                    sessions.map(t => {
                        return (
                            <div key={t.name} className="current-sessions__track">
                                <Track { ...t } />
                            </div>
                        );
                    })
                }
            </div>
        );
    }
}

export default HappeningNow;<commit_msg>Add cure for empty current sessions page<commit_after>import debug from "debug";
import React, { Component } from "react";
import Track from "../track";

const log = debug("schedule:components:happening-now");

export class HappeningNow extends Component {
    updateCurrentSessions(props) {
        const { getState } = props;
        const { current, tracks, sessions } = getState();

        this.setState({
            sessions: current.sessions.
                map(id => sessions[id]).
                reduce((a, s) => null == a.find(ss => s.track === ss.track) ? [...a, s] : a, []).
                slice(0, 3).
                map(s => ({ ...tracks[s.track], sessions: [s] }))
        });
    }

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

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

    render() {
        const { sessions } = this.state;

        return (
            <div className="current-sessions">
                {
                    0 < sessions.length
                    ? sessions.map(t => {
                        return (
                            <div key={t.name} className="current-sessions__track">
                                <Track { ...t } />
                            </div>
                        );
                    })
                    : <p>No sessions right now :-(</p>
                }
            </div>
        );
    }
}

export default HappeningNow;
{'fraction_non_alphanumeric': 0.1340782122905028, 'fraction_numerical': 0.0017458100558659217, 'mean_word_length': 1.3795681063122924, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 25, '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': '7379656', 'n_tokens_mistral': 776, 'n_tokens_neox': 735, 'n_words': 158}