本文整理汇总了Python中pybossa.cache.projects.overall_progress函数的典型用法代码示例。如果您正苦于以下问题:Python overall_progress函数的具体用法?Python overall_progress怎么用?Python overall_progress使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了overall_progress函数的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: 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
示例3: 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
示例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_overall_progres_returns_actual_progress_percentage
def test_overall_progres_returns_actual_progress_percentage(self):
total_tasks = 4
completed_tasks = 2
project = self.create_project_with_tasks(
completed_tasks=completed_tasks,
ongoing_tasks=total_tasks-completed_tasks)
progress = cached_projects.overall_progress(project.id)
assert progress == 50, progress
开发者ID:ronaldlcheung,项目名称:pybossa,代码行数:10,代码来源:test_cache_projects.py
示例8: check_contributing_state
def check_contributing_state(project, user_id=None, user_ip=None):
"""Return the state of a given project for a given user.
Depending on whether the project is completed or not and the user can
contribute more to it or not.
"""
project_id = project['id'] if type(project) == dict else project.id
states = ('completed', 'draft', 'can_contribute', 'cannot_contribute')
if overall_progress(project_id) >= 100:
return states[0]
if _has_no_presenter(project) or _has_no_tasks(project_id):
return states[1]
if n_available_tasks(project_id, user_id=user_id, user_ip=user_ip) > 0:
return states[2]
return states[3]
开发者ID:Skytim,项目名称:pybossa,代码行数:15,代码来源:helpers.py
示例9: 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
示例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: 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
示例12: test_overall_progress_returns_0_if_no_tasks
def test_overall_progress_returns_0_if_no_tasks(self):
project = ProjectFactory.create()
progress = cached_projects.overall_progress(project.id)
assert progress == 0, progress
开发者ID:ronaldlcheung,项目名称:pybossa,代码行数:6,代码来源:test_cache_projects.py
注:本文中的pybossa.cache.projects.overall_progress函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论