• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python projects.n_volunteers函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pybossa.cache.projects.n_volunteers函数的典型用法代码示例。如果您正苦于以下问题:Python n_volunteers函数的具体用法?Python n_volunteers怎么用?Python n_volunteers使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了n_volunteers函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: warm_app

 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)
开发者ID:Skytim,项目名称:pybossa,代码行数:13,代码来源:warm.py


示例2: warm_project

 def warm_project(_id, short_name, featured=False):
     if _id not in projects_cached:
         cached_projects.get_project(short_name)
         cached_projects.n_tasks(_id)
         n_task_runs = cached_projects.n_task_runs(_id)
         cached_projects.overall_progress(_id)
         cached_projects.last_activity(_id)
         cached_projects.n_completed_tasks(_id)
         cached_projects.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'))
         projects_cached.append(_id)
开发者ID:codeaudit,项目名称:pybossa,代码行数:14,代码来源:jobs.py


示例3: get_project_stats

def get_project_stats(_id, short_name):  # pragma: no cover
    """Get stats for project."""
    import pybossa.cache.projects as cached_projects
    import pybossa.cache.project_stats as stats
    from flask import current_app

    cached_projects.get_project(short_name)
    cached_projects.n_tasks(_id)
    cached_projects.n_task_runs(_id)
    cached_projects.overall_progress(_id)
    cached_projects.last_activity(_id)
    cached_projects.n_completed_tasks(_id)
    cached_projects.n_volunteers(_id)
    stats.get_stats(_id, current_app.config.get('GEO'))
开发者ID:codeaudit,项目名称:pybossa,代码行数:14,代码来源:jobs.py


示例4: update_stats

def update_stats(project_id, period='2 week'):
    """Update the stats of a given project."""
    hours, hours_anon, hours_auth, max_hours, \
        max_hours_anon, max_hours_auth = stats_hours(project_id, period)
    users, anon_users, auth_users = stats_users(project_id, period)
    dates, dates_anon, dates_auth = stats_dates(project_id, period)


    sum(dates.values())

    sorted(dates.iteritems(), key=operator.itemgetter(0))

    dates_stats = stats_format_dates(project_id, dates,
                                     dates_anon, dates_auth)

    hours_stats = stats_format_hours(project_id, hours, hours_anon, hours_auth,
                                     max_hours, max_hours_anon, max_hours_auth)

    users_stats = stats_format_users(project_id, users, anon_users, auth_users)

    data = dict(dates_stats=dates_stats,
                hours_stats=hours_stats,
                users_stats=users_stats)
    ps = session.query(ProjectStats).filter_by(project_id=project_id).first()

    n_tasks = cached_projects.n_tasks(project_id)
    n_task_runs = cached_projects.n_task_runs(project_id)
    n_results = cached_projects.n_results(project_id)
    overall_progress = cached_projects.overall_progress(project_id)
    last_activity = cached_projects.last_activity(project_id)
    n_volunteers = cached_projects.n_volunteers(project_id)
    n_completed_tasks = cached_projects.n_completed_tasks(project_id)
    average_time = cached_projects.average_contribution_time(project_id)
    n_blogposts = cached_projects.n_blogposts(project_id)

    if ps is None:
        ps = ProjectStats(project_id=project_id, info=data,
                          n_tasks=n_tasks,
                          n_task_runs=n_task_runs,
                          n_results=n_results,
                          n_volunteers=n_volunteers,
                          n_completed_tasks=n_completed_tasks,
                          average_time=average_time,
                          overall_progress=overall_progress,
                          n_blogposts=n_blogposts,
                          last_activity=last_activity)
        db.session.add(ps)
    else:
        ps.info = data
        ps.n_tasks = n_tasks
        ps.n_task_runs = n_task_runs
        ps.overall_progress = overall_progress
        ps.last_activity = last_activity
        ps.n_results = n_results
        ps.n_completed_tasks = n_completed_tasks
        ps.n_volunteers = n_volunteers
        ps.average_time = average_time
        ps.n_blogposts = n_blogposts
    db.session.commit()
    return dates_stats, hours_stats, users_stats
开发者ID:keyinfluencerplus,项目名称:tinybee.ai,代码行数:60,代码来源:project_stats.py


示例5: hidden_projects

def hidden_projects(user_id):
    """Return hidden projects for user_id."""
    sql = text(
        """
               SELECT project.id, project.name, project.short_name, project.description,
               project.owner_id,
               project.info
               FROM project, task
               WHERE project.id=task.project_id AND project.owner_id=:user_id AND
               project.hidden=1 AND (project.info->>'task_presenter') IS NOT NULL
               GROUP BY project.id, project.name, project.short_name,
               project.description;"""
    )
    projects_published = []
    results = session.execute(sql, dict(user_id=user_id))
    for row in results:
        project = dict(
            id=row.id,
            name=row.name,
            short_name=row.short_name,
            owner_id=row.owner_id,
            description=row.description,
            overall_progress=overall_progress(row.id),
            n_tasks=n_tasks(row.id),
            n_volunteers=n_volunteers(row.id),
            info=row.info,
        )
        projects_published.append(project)
    return projects_published
开发者ID:ronaldlcheung,项目名称:pybossa,代码行数:29,代码来源:users.py


示例6: projects_contributed

def projects_contributed(user_id):
    """Return projects that user_id has contributed to."""
    sql = text(
        """
               WITH apps_contributed as
                    (SELECT DISTINCT(project_id) FROM task_run
                     WHERE user_id=:user_id)
               SELECT project.id, project.name, project.short_name, project.owner_id,
               project.description, project.info FROM project, apps_contributed
               WHERE project.id=apps_contributed.project_id ORDER BY project.name DESC;
               """
    )
    results = session.execute(sql, dict(user_id=user_id))
    projects_contributed = []
    for row in results:
        project = dict(
            id=row.id,
            name=row.name,
            short_name=row.short_name,
            owner_id=row.owner_id,
            description=row.description,
            overall_progress=overall_progress(row.id),
            n_tasks=n_tasks(row.id),
            n_volunteers=n_volunteers(row.id),
            info=row.info,
        )
        projects_contributed.append(project)
    return projects_contributed
开发者ID:ronaldlcheung,项目名称:pybossa,代码行数:28,代码来源:users.py


示例7: test_n_volunteers

    def test_n_volunteers(self):
        """Test CACHE PROJECTS n_volunteers returns the sum of the anonymous
        plus registered volunteers that contributed to a project"""

        project = self.create_project_with_contributors(anonymous=2, registered=3, two_tasks=True)
        total_volunteers = cached_projects.n_volunteers(project.id)

        err_msg = "Volunteers is %s, it should be 5" % total_volunteers
        assert total_volunteers == 5, err_msg
开发者ID:ronaldlcheung,项目名称:pybossa,代码行数:9,代码来源:test_cache_projects.py


示例8: draft_projects

def draft_projects(user_id):
    """Return draft projects for user_id."""
    sql = text('''
               SELECT *
               FROM project
               WHERE project.published=false
               AND :user_id = ANY (project.owners_ids::int[]);
               ''')
    projects_draft = []
    results = session.execute(sql, dict(user_id=user_id))
    for row in results:
        project = dict(row)
        project['n_tasks'] = n_tasks(row.id)
        project['n_volunteers'] = n_volunteers(row.id)
        project['overall_progress'] = overall_progress(row.id)
        projects_draft.append(project)
    return projects_draft
开发者ID:influencerplus123,项目名称:tinybee.ai,代码行数:17,代码来源:users.py


示例9: flush_task_runs

def flush_task_runs(project_short_name, confirmed):
	project = cached_projects.get_project(project_short_name)
	if current_user.admin or project.owner_id == current_user.id:
		if confirmed == "confirmed":
			associated_task_runs = TaskRun.query.filter_by(project_id=project.id).all()
			for task_run in associated_task_runs:
				db.session.delete(task_run)
				pass
			db.session.commit()

			# Iterate over all tasks associated with the project, and mark them as 'ongoing'
			# Some tasks might be marked as 'completed' if enough task_runs were done
			associated_tasks = Task.query.filter_by(project_id=project.id).all()
			for task in associated_tasks:
				if task.state != u"ongoing":
					task.state = u"ongoing"
					db.session.commit()

			# Reset project data in the cache
			cached_projects.clean_project(project.id)
			# Note: The cache will hold the old data about the users who contributed
			# to the tasks associated with this projects till the User Cache Timeout.
			# Querying the list of contributors to this project, and then individually updating
			# their cache after that will be a very expensive query, hence we will avoid that
			# for the time being.
			flash('All Task Runs associated with this project have been successfully deleted.', 'success')
			return redirect(url_for('project.task_settings', short_name = project_short_name))
		elif confirmed == "unconfirmed":
			# Obtain data required by the project profile renderer
		    (project, owner, n_tasks, n_task_runs,
		     overall_progress, last_activity, n_results) = projects_view.project_by_shortname(project_short_name)
		    return render_template('geotagx/projects/delete_task_run_confirmation.html',
		                           project=project,
		                           owner=owner,
		                           n_tasks=n_tasks,
		                           n_task_runs=n_task_runs,
		                           overall_progress=overall_progress,
		                           last_activity=last_activity,
		                           n_results=n_results,
		                           n_completed_tasks=cached_projects.n_completed_tasks(project.id),
		                           n_volunteers=cached_projects.n_volunteers(project.id))
		else:
			abort(404)
	else:
		abort(404)
开发者ID:geotagx,项目名称:geotagx-plugin,代码行数:45,代码来源:geotagx.py


示例10: projects_contributed

def projects_contributed(user_id, order_by='name'):
    """Return projects that user_id has contributed to."""
    sql = text('''
               WITH projects_contributed as
                    (SELECT project_id, MAX(finish_time) as last_contribution  FROM task_run
                     WHERE user_id=:user_id GROUP BY project_id)
               SELECT * FROM project, projects_contributed
               WHERE project.id=projects_contributed.project_id ORDER BY {} DESC;
               '''.format(order_by))
    results = session.execute(sql, dict(user_id=user_id))
    projects_contributed = []
    for row in results:
        project = dict(row)
        project['n_tasks'] = n_tasks(row.id)
        project['n_volunteers'] = n_volunteers(row.id)
        project['overall_progress'] = overall_progress(row.id)
        projects_contributed.append(project)
    return projects_contributed
开发者ID:influencerplus123,项目名称:tinybee.ai,代码行数:18,代码来源:users.py


示例11: visualize

def visualize(short_name, task_id):
  """Return a file with all the TaskRuns for a given Task"""
  # Check if it a supported geotagx project whose schema we know
  if 'GEOTAGX_SUPPORTED_PROJECTS_SCHEMA' in current_app.config.keys() \
		and short_name in current_app.config['GEOTAGX_SUPPORTED_PROJECTS_SCHEMA'].keys():
	  # Check if the project exists
	  (project, owner, n_tasks, n_task_runs,
	   overall_progress, last_activity) = projects_view.project_by_shortname(short_name)

	  ensure_authorized_to('read', project)
	  redirect_to_password = projects_view._check_if_redirect_to_password(project)
	  if redirect_to_password:
	      return redirect_to_password

	  # Check if the task belongs to the project and exists
	  task = task_repo.get_task_by(project_id=project.id, id=task_id)
	  if task:
	      taskruns = task_repo.filter_task_runs_by(task_id=task_id, project_id=project.id)
	      results = [tr.dictize() for tr in taskruns]
	      return render_template('geotagx/projects/task_runs_visualize.html',
			                           project=project,
			                           owner=owner,
			                           n_tasks=n_tasks,
			                           n_task_runs=n_task_runs,
			                           overall_progress=overall_progress,
			                           last_activity=last_activity,
			                           n_completed_tasks=cached_projects.n_completed_tasks(project.id),
			                           n_volunteers=cached_projects.n_volunteers(project.id),
			                           task_info = task.info,
			                           task_runs_json = results,
			                           geotagx_project_template_schema = \
			                           	current_app.config['GEOTAGX_SUPPORTED_PROJECTS_SCHEMA'][short_name])
	  else:
	      return abort(404)
  else:
  	return abort(404)
开发者ID:geotagx,项目名称:geotagx-plugin,代码行数:36,代码来源:geotagx.py


示例12: published_projects

def published_projects(user_id):
    """Return published projects for user_id."""
    sql = text('''
               SELECT project.id, project.name, project.short_name, project.description,
               project.owner_id,
               project.info
               FROM project, task
               WHERE project.id=task.project_id AND project.owner_id=:user_id AND
               project.hidden=0 AND project.info LIKE('%task_presenter%')
               GROUP BY project.id, project.name, project.short_name,
               project.description,
               project.info;''')
    projects_published = []
    results = session.execute(sql, dict(user_id=user_id))
    for row in results:
        project = dict(id=row.id, name=row.name, short_name=row.short_name,
                       owner_id=row.owner_id,
                       description=row.description,
                       overall_progress=overall_progress(row.id),
                       n_tasks=n_tasks(row.id),
                       n_volunteers=n_volunteers(row.id),
                       info=json.loads(row.info))
        projects_published.append(project)
    return projects_published
开发者ID:inteligencia-coletiva-lsd,项目名称:pybossa,代码行数:24,代码来源:users.py



注:本文中的pybossa.cache.projects.n_volunteers函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python projects.overall_progress函数代码示例发布时间:2022-05-25
下一篇:
Python projects.n_tasks函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap