<commit_before>// @flow

import React from 'react';
import PropTypes from 'prop-types';

import Paper from 'material-ui/Paper';
import { Tabs, Tab } from 'material-ui/Tabs';
import { List, ListItem } from 'material-ui/List';
import Subheader from 'material-ui/Subheader';
import Avatar from 'material-ui/Avatar';

class CastList extends React.Component {

    static propTypes = {
        show: PropTypes.object,
    };

    renderDivider(title) {
        return (
            <Subheader
                key={title}
            >
                {title}
            </Subheader>
        );
    }

    renderItem(role, person) {
        return (
            <ListItem
                key={person.id}
                disabled={true}
                primaryText={person.name}
                secondaryText={role}
                leftAvatar={<Avatar src="images/avatar.png" />}
            />
        );
    };

    renderMainCastList() {
        const { show } = this.props;
        if (!show || !show.cast) {
            return (
                <div />
            );
        }

        // TODO FIXME Be more flexible in terms of number of elements
        // TODO FIXME Deal with absent information
        const cast = show.cast;
        return [
            this.renderDivider('Hauptrollen'),
            this.renderItem('<NAME>', cast['Graf von Krolock'][0]),
            this.renderItem('Alfred', cast['Alfred'][0]),
            this.renderItem('Professor Abronsius', cast['Professor Abronsius'][0]),
            this.renderItem('Sarah', cast['Sarah'][0]),
            this.renderItem('Chagal', cast['Chagal'][0]),
            this.renderItem('Magda', cast['Magda'][0]),
            this.renderItem('Rebecca', cast['Rebecca'][0]),
            this.renderItem('Herbert', cast['Herbert'][0]),
            this.renderItem('Koukol', cast['Koukol'][0]),
            this.renderDivider('Dirigent'),
            this.renderItem('Dirigent', cast['Dirigent'][0]),
        ];
    };

    renderEnsembleGroup(group) {
        const { show } = this.props;
        return show.cast[group].map((person) => {
            return this.renderItem('', person);
        });
    };

    renderEnsembleList() {
        const { show } = this.props;
        if (!show || !show.cast) {
            return (
                <div />
            );
        }

        // TODO FIXME Deal with absent types
        // TODO FIXME Add Gesangssolisten
        const cast = show.cast;
        return [
            this.renderDivider('Tanzsolisten'),
            ...this.renderEnsembleGroup('Solotänzer'),
            this.renderDivider('Tanzensemble'),
            ...this.renderEnsembleGroup('Tanzensemble'),
            this.renderDivider('Gesangsensemble'),
            ...this.renderEnsembleGroup('Gesangsensemble'),
        ];
    };

    render() {
        const { show } = this.props;
        if (!show) {
            return (
                <div />
            );
        }

        const styles = {
            root: {
                maxWidth: 400,
                margin: '0 auto',<commit_msg>Render Gesangssolisten and deal with absent Ensemble groups<commit_after>// @flow

import React from 'react';
import PropTypes from 'prop-types';

import Paper from 'material-ui/Paper';
import { Tabs, Tab } from 'material-ui/Tabs';
import { List, ListItem } from 'material-ui/List';
import Subheader from 'material-ui/Subheader';
import Avatar from 'material-ui/Avatar';

class CastList extends React.Component {

    static propTypes = {
        show: PropTypes.object,
    };

    renderDivider(title) {
        return (
            <Subheader
                key={title}
            >
                {title}
            </Subheader>
        );
    }

    renderItem(role, person) {
        return (
            <ListItem
                key={person.id}
                disabled={true}
                primaryText={person.name}
                secondaryText={role}
                leftAvatar={<Avatar src="images/avatar.png" />}
            />
        );
    };

    renderMainCastList() {
        const { show } = this.props;
        if (!show || !show.cast) {
            return (
                <div />
            );
        }

        // TODO FIXME Be more flexible in terms of number of elements
        // TODO FIXME Deal with absent information
        const cast = show.cast;
        return [
            this.renderDivider('Hauptrollen'),
            this.renderItem('<NAME>', cast['<NAME>'][0]),
            this.renderItem('Alfred', cast['Alfred'][0]),
            this.renderItem('Professor Abronsius', cast['Professor Abronsius'][0]),
            this.renderItem('Sarah', cast['Sarah'][0]),
            this.renderItem('Chagal', cast['Chagal'][0]),
            this.renderItem('Magda', cast['Magda'][0]),
            this.renderItem('Rebecca', cast['Rebecca'][0]),
            this.renderItem('Herbert', cast['Herbert'][0]),
            this.renderItem('Koukol', cast['Koukol'][0]),
            this.renderDivider('Dirigent'),
            this.renderItem('Dirigent', cast['Dirigent'][0]),
        ];
    };

    renderEnsembleGroup(label, key) {
        const { show } = this.props;
        if (!show.cast[key] || show.cast[key].length === 0) {
            return [];
        }

        const divider = this.renderDivider(label);
        return [divider].concat(
            show.cast[key].map((person) => {
                return this.renderItem('', person);
            })
        );
    };

    renderEnsembleList() {
        const { show } = this.props;
        if (!show || !show.cast) {
            return (
                <div />
            );
        }

        const cast = show.cast;
        return [
            ...this.renderEnsembleGroup('Tanzsolisten', 'Solotänzer'),
            ...this.renderEnsembleGroup('Gesangssolisten', 'Gesangssolisten'),
            ...this.renderEnsembleGroup('Tanzensemble', 'Tanzensemble'),
            ...this.renderEnsembleGroup('Gesangsensemble', 'Gesangsensemble'),
        ];
    };

    render() {
        const { show } = this.props;
        if (!show) {
            return (
                <div />
            );
        }

        const styles = {
            root: {
                maxWidth: 400,
                margin: '0 auto',
{'fraction_non_alphanumeric': 0.14044585987261146, 'fraction_numerical': 0.0046178343949044584, 'mean_word_length': 1.6614406779661017, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 22, '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': '7372929', 'n_tokens_mistral': 1795, 'n_tokens_neox': 1743, 'n_words': 338}