コード例 #1
0
ファイル: warm.py プロジェクト: Krispy2009/pybossa
 def warm_app(id, short_name, featured=False):
     if id not in apps_cached:
         cached_apps.get_app(short_name)
         cached_apps.n_tasks(id)
         n_task_runs = cached_apps.n_task_runs(id)
         cached_apps.overall_progress(id)
         cached_apps.last_activity(id)
         cached_apps.n_completed_tasks(id)
         cached_apps.n_volunteers(id)
         if n_task_runs >= 1000 or featured:
             print "Getting stats for %s as it has %s task runs" % (short_name, n_task_runs)
             stats.get_stats(id, app.config.get('GEO'))
         apps_cached.append(id)
コード例 #2
0
ファイル: warm.py プロジェクト: fesp21/pybossa
 def warm_app(id, short_name):
     if id not in apps_cached:
         cached_apps.get_app(short_name)
         cached_apps.n_tasks(id)
         n_task_runs = cached_apps.n_task_runs(id)
         cached_apps.overall_progress(id)
         cached_apps.last_activity(id)
         cached_apps.n_completed_tasks(id)
         cached_apps.n_volunteers(id)
         if n_task_runs >= 1000:
             print "Getting stats for %s as it has %s" % (id,
                                                          n_task_runs)
             stats.get_stats(id, app.config.get('GEO'))
         apps_cached.append(id)
コード例 #3
0
ファイル: jobs.py プロジェクト: IdahoInstitute/pybossa
def get_app_stats(id, short_name): # pragma: no cover
    """Get stats for app."""
    import pybossa.cache.apps as cached_apps
    import pybossa.cache.project_stats as stats
    from flask import current_app

    cached_apps.get_app(short_name)
    cached_apps.n_tasks(id)
    cached_apps.n_task_runs(id)
    cached_apps.overall_progress(id)
    cached_apps.last_activity(id)
    cached_apps.n_completed_tasks(id)
    cached_apps.n_volunteers(id)
    stats.get_stats(id, current_app.config.get('GEO'))
コード例 #4
0
ファイル: jobs.py プロジェクト: idahoan/pybossa
def get_app_stats(id, short_name): # pragma: no cover
    """Get stats for app."""
    import pybossa.cache.apps as cached_apps
    import pybossa.cache.project_stats as stats
    from flask import current_app

    cached_apps.get_app(short_name)
    cached_apps.n_tasks(id)
    cached_apps.n_task_runs(id)
    cached_apps.overall_progress(id)
    cached_apps.last_activity(id)
    cached_apps.n_completed_tasks(id)
    cached_apps.n_volunteers(id)
    stats.get_stats(id, current_app.config.get('GEO'))
コード例 #5
0
def app_index(page, lookup, category, fallback, use_count):
    """Show apps of app_type"""

    per_page = 5
    # @FC to come back to project homepage from the application detail
    if 'cat_byapp_' in category:
        category = get_app_category(category.replace("cat_byapp_", ""))

    # @FC
    apps, count = lookup(category, page, per_page)

    data = []
    #for app in apps:
    #    if 'tutorial' in app['short_name']:
    #        data.append(dict(app=app, n_tasks=cached_apps.n_tasks(app['id']),
    #                         overall_progress=cached_apps.overall_progress(app['id']),
    #                         last_activity=cached_apps.last_activity(app['id'])))
    for app in apps:
        if 'tutorial' not in app['short_name']:
            data.append(dict(app=app, n_tasks=cached_apps.n_tasks(app['id']),
                             overall_progress=cached_apps.overall_progress(app['id']),
                             last_activity=cached_apps.last_activity(app['id'])))

    if fallback and not apps:
        return redirect(url_for('.published'))

    pagination = Pagination(page, per_page, count)
    categories = cached_cat.get_all()
    # Check for pre-defined categories featured and draft
    featured_cat = model.Category(name='Featured',
                                  short_name='featured',
                                  description='Featured applications')
    if category == 'featured':
        active_cat = featured_cat
    elif category == 'draft':
        active_cat = model.Category(name='Draft',
                                    short_name='draft',
                                    description='Draft applications')
    else:
        active_cat = db.session.query(model.Category)\
                       .filter_by(short_name=category).first()

    # Check if we have to add the section Featured to local nav
    if cached_apps.n_featured() > 0:
        categories.insert(0, featured_cat)
    template_args = {
        "apps": data,
        "title": gettext("Applications"),
        "pagination": pagination,
        "active_cat": active_cat,
        "n_apps_per_category": None,
        "categories": categories}

    n_apps_per_category = dict()
    for c in categories:
        n_apps_per_category[c.short_name] = cached_apps.n_count(c.short_name)
    template_args['n_apps_per_category'] = n_apps_per_category
    if use_count:
        template_args.update({"count": count})
    return render_template('/applications/index.html', **template_args)
コード例 #6
0
ファイル: applications.py プロジェクト: lolkins/pybossa
def app_by_shortname(short_name):
    app = cached_apps.get_app(short_name)
    if app.id:
        # Populate CACHE with the data of the app
        return (app, cached_apps.n_tasks(app.id),
                cached_apps.n_task_runs(app.id),
                cached_apps.overall_progress(app.id),
                cached_apps.last_activity(app.id))

    else:
        return abort(404)
コード例 #7
0
ファイル: applications.py プロジェクト: rkyymmt/pybossa
def app_by_shortname(short_name):
    app = cached_apps.get_app(short_name)
    if app.id:
        # Populate CACHE with the data of the app
        return (app,
                cached_apps.n_tasks(app.id),
                cached_apps.n_task_runs(app.id),
                cached_apps.overall_progress(app.id),
                cached_apps.last_activity(app.id))

    else:
        return abort(404)
コード例 #8
0
ファイル: applications.py プロジェクト: lolkins/pybossa
def app_index(page, lookup, category, fallback, use_count):
    """Show apps of app_type"""

    per_page = 5

    apps, count = lookup(category, page, per_page)

    data = []
    for app in apps:
        data.append(
            dict(app=app,
                 n_tasks=cached_apps.n_tasks(app['id']),
                 overall_progress=cached_apps.overall_progress(app['id']),
                 last_activity=cached_apps.last_activity(app['id'])))

    if fallback and not apps:
        return redirect(url_for('.published'))

    pagination = Pagination(page, per_page, count)
    categories = cached_cat.get_all()
    # Check for pre-defined categories featured and draft
    featured_cat = model.Category(name='Featured',
                                  short_name='featured',
                                  description='Featured applications')
    if category == 'featured':
        active_cat = featured_cat
    elif category == 'draft':
        active_cat = model.Category(name='Draft',
                                    short_name='draft',
                                    description='Draft applications')
    else:
        active_cat = db.session.query(model.Category)\
                       .filter_by(short_name=category).first()

    # Check if we have to add the section Featured to local nav
    if cached_apps.n_featured() > 0:
        categories.insert(0, featured_cat)
    template_args = {
        "apps": data,
        "title": gettext("Applications"),
        "pagination": pagination,
        "active_cat": active_cat,
        "categories": categories
    }

    if use_count:
        template_args.update({"count": count})
    return render_template('/applications/index.html', **template_args)
コード例 #9
0
ファイル: applications.py プロジェクト: rkyymmt/pybossa
def app_index(page, lookup, category, fallback, use_count):
    """Show apps of app_type"""

    per_page = 5

    apps, count = lookup(category, page, per_page)

    data = []
    for app in apps:
        data.append(dict(app=app, n_tasks=cached_apps.n_tasks(app['id']),
                         overall_progress=cached_apps.overall_progress(app['id']),
                         last_activity=cached_apps.last_activity(app['id'])))


    if fallback and not apps:
        return redirect(url_for('.published'))

    pagination = Pagination(page, per_page, count)
    categories = cached_cat.get_all()
    # Check for pre-defined categories featured and draft
    featured_cat = model.Category(name='Featured',
                                  short_name='featured',
                                  description='Featured applications')
    if category == 'featured':
        active_cat = featured_cat
    elif category == 'draft':
        active_cat = model.Category(name='Draft',
                                    short_name='draft',
                                    description='Draft applications')
    else:
        active_cat = db.session.query(model.Category)\
                       .filter_by(short_name=category).first()

    # Check if we have to add the section Featured to local nav
    if cached_apps.n_featured() > 0:
        categories.insert(0, featured_cat)
    template_args = {
        "apps": data,
        "title": gettext("Applications"),
        "pagination": pagination,
        "active_cat": active_cat,
        "categories": categories}

    if use_count:
        template_args.update({"count": count})
    return render_template('/applications/index.html', **template_args)