def get_top(n=4):
"""Return top n=4 projects."""
sql = text('''SELECT project.id, project.name, project.short_name, project.description,
project.info,
COUNT(project_id) AS total
FROM task_run, project
WHERE project_id IS NOT NULL
AND project.id=project_id
AND (project.info->>'passwd_hash') IS NULL
GROUP BY project.id ORDER BY total DESC LIMIT :limit;''')
results = session.execute(sql, dict(limit=n))
top_projects = []
for row in results:
project = dict(id=row.id, name=row.name, short_name=row.short_name,
description=row.description,
info=row.info,
n_volunteers=n_volunteers(row.id),
n_completed_tasks=n_completed_tasks(row.id))
top_projects.append(Project().to_public_json(project))
return top_projects
#@memoize(timeout=timeouts.get('BROWSE_TASKS_TIMEOUT'))
评论列表
文章目录