<commit_before>"use strict";

import * as m from 'mithril';
import { Vnode } from 'mithril';
import View from '../../View';
import LiveWatchOtherStreamInfoViewModel from '../../../ViewModel/Live/Watch/LiveWatchOtherStreamInfoViewModel';
import DateUtil from '../../../Util/DateUtil';

/**
* LiveWatchOtherStreamInfoView の View
*/
class LiveWatchOtherStreamInfoView extends View {
    private viewModel: LiveWatchOtherStreamInfoViewModel;

    public execute(): Vnode<any, any> {
        this.viewModel = <LiveWatchOtherStreamInfoViewModel>this.getModel("LiveWatchOtherStreamInfoViewModel");

        let info = this.viewModel.getOtherStreamInfo();
        if(info.length == 0) { return m(""); }

        return m("div", { class: "live-program mdl-card mdl-shadow--2dp mdl-cell mdl-cell--12-col" }, [
            m("div", { class: "mdl-card__supporting-text" }, [
                m("div", { class: "live-program-description" }, [ "配信中" ]),
                this.createCard(info)
            ])
        ]);
    }

    private createCard(info: any[]): Vnode<any, any>[] {
        let result: Vnode<any, any>[] = [];

        info.map((data: { [key: string]: any }) => {
            result.push(
                m("a", { class: "card-link", href: `/live/watch?stream=${ data["streamNumber"] }`, oncreate: m.route.link }, [
                    m("div", { class: "program-station-name" }, data["name"]),
                    m("div", { class: "program-time" }, `${ this.getFormatedDate(data["starttime"]) } ~ ${ this.getFormatedDate(data["endtime"]) }`),
                    m("div", { class: "program-title" }, data["title"]),
                    m("div", { class: "program-description" }, data["description"])
                ])
            );
            result.push( m("hr", { class: ".card-line" } ) );
        });

        result.pop();
        return result;
    }

    /**
    * Date を hh:mm 形式に変換する
    * @param date string型
    */
    private getFormatedDate(date: string): string {
        return DateUtil.format(DateUtil.getJaDate(new Date(date)), "hh:mm");
    }
}

export default LiveWatchOtherStreamInfoView;

<commit_msg>live か recorded 以外は /live/watch の配信中の一覧に表示しないようにした<commit_after>"use strict";

import * as m from 'mithril';
import { Vnode } from 'mithril';
import View from '../../View';
import LiveWatchOtherStreamInfoViewModel from '../../../ViewModel/Live/Watch/LiveWatchOtherStreamInfoViewModel';
import DateUtil from '../../../Util/DateUtil';

/**
* LiveWatchOtherStreamInfoView の View
*/
class LiveWatchOtherStreamInfoView extends View {
    private viewModel: LiveWatchOtherStreamInfoViewModel;

    public execute(): Vnode<any, any> {
        this.viewModel = <LiveWatchOtherStreamInfoViewModel>this.getModel("LiveWatchOtherStreamInfoViewModel");

        let info = this.viewModel.getOtherStreamInfo();
        if(info.length == 0) { return m(""); }

        let content = this.createCard(info);
        if(content.length == 0) { return m(""); }

        return m("div", { class: "live-program mdl-card mdl-shadow--2dp mdl-cell mdl-cell--12-col" }, [
            m("div", { class: "mdl-card__supporting-text" }, [
                m("div", { class: "live-program-description" }, [ "配信中" ]),
                content
            ])
        ]);
    }

    private createCard(info: any[]): Vnode<any, any>[] {
        let result: Vnode<any, any>[] = [];

        info.map((data: { [key: string]: any }) => {
            console.log(data["streamType"]);
            if(data["streamType"] != "live" && data["streamType"] != "recorded") { return; };
            result.push(
                m("a", { class: "card-link", href: `/live/watch?stream=${ data["streamNumber"] }`, oncreate: m.route.link }, [
                    m("div", { class: "program-station-name" }, data["name"]),
                    m("div", { class: "program-time" }, `${ this.getFormatedDate(data["starttime"]) } ~ ${ this.getFormatedDate(data["endtime"]) }`),
                    m("div", { class: "program-title" }, data["title"]),
                    m("div", { class: "program-description" }, data["description"])
                ])
            );
            result.push( m("hr", { class: ".card-line" } ) );
        });

        result.pop();
        return result;
    }

    /**
    * Date を hh:mm 形式に変換する
    * @param date string型
    */
    private getFormatedDate(date: string): string {
        return DateUtil.format(DateUtil.getJaDate(new Date(date)), "hh:mm");
    }
}

export default LiveWatchOtherStreamInfoView;


{'fraction_non_alphanumeric': 0.1753764393268379, 'fraction_numerical': 0.001992914083259522, 'mean_word_length': 2.4934261407579275, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, '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': '6200150', 'n_tokens_mistral': 1406, 'n_tokens_neox': 1362, 'n_words': 270}