<commit_before>import m from 'mithril';
import _ from 'underscore';
import { catarse, commonPayment } from '../api';
import models from '../models';
import h from '../h';
import loadMoreBtn from '../c/load-more-btn';
import projectDashboardMenu from '../c/project-dashboard-menu';
import dashboardSubscriptionCard from '../c/dashboard-subscription-card';
import projectsContributionReportVM from '../vms/projects-contribution-report-vm';

const projectSubscriptionReport = {
    controller(args) {
        const filterVM = projectsContributionReportVM,
            error = m.prop(false),
            loader = m.prop(true),
            handleError = () => {
                error(true);
                loader(false);
                m.redraw();
            },
            subscriptions = commonPayment.paginationVM(models.userSubscription, 'created_at.desc', {
                Prefer: 'count=exact'
            }),
            contextSubVM = catarse.filtersVM({
                status: 'in'
            }),
            project = m.prop([{}]);

        contextSubVM.status(['started', 'active', 'inactive', 'canceled', 'error']);
        filterVM.project_id(args.project_id);

        const lProject = catarse.loaderWithToken(models.projectDetail.getPageOptions({
            project_id: `eq.${filterVM.project_id()}`
        }));

        lProject.load().then((data) => {
            subscriptions.firstPage(contextSubVM.parameters()).then(() => {
                loader(false);
            }).catch(handleError);
            project(data);
        });

        return {
            filterVM,
            subscriptions,
            lProject,
            project
        };
    },
    view(ctrl) {
        const subsCollection = ctrl.subscriptions.collection();
        console.log(subsCollection);
        if (!ctrl.lProject()) {
            return m('div', [
                m.component(projectDashboardMenu, {
                    project: m.prop(_.first(ctrl.project()))
                }),<commit_msg>remove console.log<commit_after>import m from 'mithril';
import _ from 'underscore';
import { catarse, commonPayment } from '../api';
import models from '../models';
import h from '../h';
import loadMoreBtn from '../c/load-more-btn';
import projectDashboardMenu from '../c/project-dashboard-menu';
import dashboardSubscriptionCard from '../c/dashboard-subscription-card';
import projectsContributionReportVM from '../vms/projects-contribution-report-vm';

const projectSubscriptionReport = {
    controller(args) {
        const filterVM = projectsContributionReportVM,
            error = m.prop(false),
            loader = m.prop(true),
            handleError = () => {
                error(true);
                loader(false);
                m.redraw();
            },
            subscriptions = commonPayment.paginationVM(models.userSubscription, 'created_at.desc', {
                Prefer: 'count=exact'
            }),
            contextSubVM = catarse.filtersVM({
                status: 'in'
            }),
            project = m.prop([{}]);

        contextSubVM.status(['started', 'active', 'inactive', 'canceled', 'error']);
        filterVM.project_id(args.project_id);

        const lProject = catarse.loaderWithToken(models.projectDetail.getPageOptions({
            project_id: `eq.${filterVM.project_id()}`
        }));

        lProject.load().then((data) => {
            subscriptions.firstPage(contextSubVM.parameters()).then(() => {
                loader(false);
            }).catch(handleError);
            project(data);
        });

        return {
            filterVM,
            subscriptions,
            lProject,
            project
        };
    },
    view(ctrl) {
        const subsCollection = ctrl.subscriptions.collection();
        if (!ctrl.lProject()) {
            return m('div', [
                m.component(projectDashboardMenu, {
                    project: m.prop(_.first(ctrl.project()))
                }),
{'fraction_non_alphanumeric': 0.13606639839034204, 'fraction_numerical': 0.0, 'mean_word_length': 1.983495873968492, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '4613641', 'n_tokens_mistral': 1048, 'n_tokens_neox': 1027, 'n_words': 188}