<commit_before><template>
    <div>
        <div class="modpanel__header">
            <div class="modpanel__header-main">
                <h1 class="modpanel__header-title">{{ game.timestamp | moment('mediumDate')}}</h1>
                <h2 class="modpanel__header-subtitle">
                    #{{ game.id }}
                    &nbsp;&nbsp;/&nbsp;&nbsp;
                    S{{ game.season}}
                    &nbsp;&nbsp;/&nbsp;&nbsp;
                    {{ game.name }}
                    &nbsp;&nbsp;/&nbsp;&nbsp;
                    <strong class="color-warning">{{ game.active ? 'Active' : 'Preparing'}}</strong>
                </h2>
            </div>

            <div class="modpanel__header-actions">
                <a href="/mod/games" class="btn btn-outline-gray">Back</a>
                <button v-show="!game.done && !game.active" v-async-click="[activate]"
                        class="btn btn-primary">
                    Activate
                </button>
                <button v-async-click="[save]" class="btn btn-primary">Save</button>
                <button async-click="mod.delete()" class="btn btn-secondary">Delete</button>
            </div>
        </div>

        <nav class="nav-tabs">
            <nuxt-link :to="'/mod/game/details?game=' + game.id" class="nav-tabs__item">Details</nuxt-link>
            <nuxt-link :to="'/mod/game/brief?game=' + game.id" class="nav-tabs__item">Brief</nuxt-link>
        </nav>

        <nuxt/>
    </div>
</template>

<script>
    import Component, {State} from 'nuxt-class-component';
    import Vue from 'vue';
    import Http from "../../services/Http";

    @Component({
        components: {}
    })
    export default class DashboardGame extends Vue {
        @State(state => state.game.game) game;

        async activate() {
            this.game.active = true;

            await this.save();
        }

        async save() {
            let cloned = {...this.game};
            delete cloned.teams;

            let game = await Http.for('game').save(cloned);

            this.$store.commit('game/game', game);
        }

        async fetch({store, query}) {<commit_msg>Saving teams<commit_after><template>
    <div>
        <div class="modpanel__header">
            <div class="modpanel__header-main">
                <h1 class="modpanel__header-title">{{ game.timestamp | moment('mediumDate')}}</h1>
                <h2 class="modpanel__header-subtitle">
                    #{{ game.id }}
                    &nbsp;&nbsp;/&nbsp;&nbsp;
                    S{{ game.season}}
                    &nbsp;&nbsp;/&nbsp;&nbsp;
                    {{ game.name }}
                    &nbsp;&nbsp;/&nbsp;&nbsp;
                    <strong class="color-warning">{{ game.active ? 'Active' : 'Preparing'}}</strong>
                </h2>
            </div>

            <div class="modpanel__header-actions">
                <a href="/mod/games" class="btn btn-outline-gray">Back</a>
                <button v-show="!game.done && !game.active" v-async-click="[activate]"
                        class="btn btn-primary">
                    Activate
                </button>
                <button v-async-click="[save]" class="btn btn-primary">Save</button>
                <button async-click="mod.delete()" class="btn btn-secondary">Delete</button>
            </div>
        </div>

        <nav class="nav-tabs">
            <nuxt-link :to="'/mod/game/details?game=' + game.id" class="nav-tabs__item">Details</nuxt-link>
            <nuxt-link :to="'/mod/game/brief?game=' + game.id" class="nav-tabs__item">Brief</nuxt-link>
        </nav>

        <nuxt/>
    </div>
</template>

<script>
    import Component, {State} from 'nuxt-class-component';
    import Vue from 'vue';
    import Http from "../../services/Http";

    @Component({
        components: {}
    })
    export default class DashboardGame extends Vue {
        @State(state => state.game.game) game;

        async activate() {
            this.game.active = true;

            await this.save();
        }

        async save() {
            let cloned = {...this.game};
            delete cloned.teams;

           let game = await Http.for('game').save(cloned);

            Object.values(this.game.teams).forEach(async team => {
                let result = await Http.for('game/team').save(team);

                game.teams[result.name] = result;
            });

            this.$store.commit('game/game', game);
        }

        async fetch({store, query}) {
{'fraction_non_alphanumeric': 0.16357206012378425, 'fraction_numerical': 0.0017683465959328027, 'mean_word_length': 1.6570757486788021, 'pattern_counts': {'":': 0, '<': 67, '<?xml version=': 0, '>': 70, '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': '2084839', 'n_tokens_mistral': 1341, 'n_tokens_neox': 1264, 'n_words': 231}