示例#1
0
    def test_charts(self):
        """Test project chart"""
        return  #to fix
        date_old = (datetime.datetime.utcnow() -
                    datetime.timedelta(30 * 36)).isoformat()
        date_4_mo = (datetime.datetime.utcnow() -
                     datetime.timedelta(120)).isoformat()
        date_3_mo = (datetime.datetime.utcnow() -
                     datetime.timedelta(90)).isoformat()
        date_2_mo = (datetime.datetime.utcnow() -
                     datetime.timedelta(60)).isoformat()
        date_1_mo = (datetime.datetime.utcnow() -
                     datetime.timedelta(30)).isoformat()
        expected_tasks = 6
        expected_categories = 2
        expected_projects = 4
        expected_taskruns = 5

        CategoryFactory.create(created=date_1_mo)
        CategoryFactory.create(created=date_2_mo)
        CategoryFactory.create(created=date_3_mo)

        ProjectFactory.create(created=date_1_mo)
        ProjectFactory.create(created=date_2_mo)
        ProjectFactory.create(created=date_3_mo)
        ProjectFactory.create(created=date_4_mo)
        ProjectFactory.create(created=date_old)

        TaskFactory.create(created=date_1_mo)
        TaskFactory.create(created=date_2_mo)
        TaskFactory.create(created=date_3_mo)

        TaskRunFactory.create(created=date_1_mo)
        TaskRunFactory.create(created=date_2_mo)
        TaskRunFactory.create(created=date_3_mo)
        TaskRunFactory.create(created=date_4_mo)
        TaskRunFactory.create(created=date_old)

        projects = stats.project_chart()
        assert projects['series'][0][
            24] == expected_projects, "{} projects created in last 24 months".format(
                expected_projects)
        categories = stats.category_chart()
        assert categories['series'][0][
            24] == expected_categories, "{} categories created in last 24 months".format(
                expected_categories)
        tasks = stats.task_chart()
        assert tasks['series'][0][
            24] == expected_tasks, "{} tasks created in last 24 months".format(
                expected_tasks)
        taskruns = stats.submission_chart()
        assert taskruns['series'][0][
            24] == expected_taskruns, "{} taskruns created in last 24 months".format(
                expected_taskruns)
示例#2
0
def management_dashboard():
    if not site_stats.management_dashboard_stats_cached():
        flash(
            'Management dashboard is calculating the statistics. Please return to this page after receiving notification.',
            'warning')
        DASHBOARD_QUEUE.enqueue(get_management_dashboard_stats,
                                current_user.email_addr)
        return redirect_content_type(url_for('admin.index'))

    # charts
    project_chart = site_stats.project_chart()
    category_chart = site_stats.category_chart()
    task_chart = site_stats.task_chart()
    submission_chart = site_stats.submission_chart()
    current_app.logger.info(task_chart)

    # General platform usage
    timed_stats_funcs = [
        site_stats.number_of_active_jobs, site_stats.number_of_created_jobs,
        site_stats.number_of_created_tasks,
        site_stats.number_of_completed_tasks,
        site_stats.avg_time_to_complete_task,
        site_stats.number_of_active_users,
        site_stats.categories_with_new_projects
    ]

    # Work on platform
    current_stats_funcs = [
        site_stats.avg_task_per_job, site_stats.tasks_per_category
    ]

    timed_stats = OrderedDict()
    for func in timed_stats_funcs:
        timed_stats[func.__doc__] = OrderedDict()
        for days in [30, 60, 90, 350, 'all']:
            timed_stats[func.__doc__][days] = func(days)

    current_stats = OrderedDict((func.__doc__, func())  #TODO : uncomment later
                                for func in current_stats_funcs)

    return render_template('admin/management_dashboard.html',
                           timed_stats=timed_stats,
                           current_stats=current_stats,
                           project_chart=project_chart,
                           category_chart=category_chart,
                           task_chart=task_chart,
                           submission_chart=submission_chart)
示例#3
0
def management_dashboard():
    project_chart = site_stats.project_chart()
    category_chart = site_stats.category_chart()
    task_chart = site_stats.task_chart()
    submission_chart = site_stats.submission_chart()
    current_app.logger.info(task_chart)

    timed_stats_funcs = [
        site_stats.number_of_active_jobs, site_stats.number_of_created_jobs,
        site_stats.number_of_created_tasks,
        site_stats.number_of_completed_tasks,
        site_stats.avg_time_to_complete_task,
        site_stats.number_of_active_users,
        site_stats.categories_with_new_projects
    ]

    current_stats_funcs = [
        site_stats.avg_task_per_job, site_stats.tasks_per_category
    ]

    timed_stats = OrderedDict()
    for func in timed_stats_funcs:
        timed_stats[func.__doc__] = OrderedDict()
        for days in [30, 60, 90, 350, 'all']:
            timed_stats[func.__doc__][days] = func(days)

    current_stats = OrderedDict(
        (func.__doc__, func()) for func in current_stats_funcs)

    return render_template('admin/management_dashboard.html',
                           timed_stats=timed_stats,
                           current_stats=current_stats,
                           project_chart=project_chart,
                           category_chart=category_chart,
                           task_chart=task_chart,
                           submission_chart=submission_chart)