def api_publisher_task_head(auth_user=None, api_core=None, request=None): u""" Return an array containing the publication tasks serialized as JSON. The publication tasks attributes are appended with the Celery's ``async result`` of the tasks. """ data = get_request_data(request, accepted_keys=api_core.db_find_keys, qs_only_first_value=True, optional=True) return ok_200(api_core.get_publisher_tasks(**data), include_properties=True)
def api_publisher_task_get(auth_user=None, api_core=None, request=None): u""" Return an array containing the publication tasks serialized to JSON. The publication tasks attributes are appended with the Celery's ``async result`` of the tasks. All ``thing_id`` fields are replaced by corresponding ``thing``. For example ``user_id`` is replaced by ``user``'s data. """ data = get_request_data(request, accepted_keys=api_core.db_find_keys, qs_only_first_value=True, optional=True) return ok_200(api_core.get_publisher_tasks(load_fields=True, **data), include_properties=True)
def view_publisher_tasks_list(request): u"""Show the publication tasks list page.""" try: data = get_request_data(request, accepted_keys=api_core.db_find_keys, qs_only_first_value=True, optional=True) data.setdefault(u'skip', 50) # ask for the last 50 media assets if skip is not provided tasks = remove_underscores(api_core.get_publisher_tasks(**data)) for task in tasks: task.media = remove_underscores(api_core.get_media(spec={u'_id': task.media_id})) task.statistic[u'elapsed_time'] = secs_to_time(task.statistic.get(u'elapsed_time', 0)).strftime(u'%H:%M:%S') task.statistic[u'eta_time'] = secs_to_time(task.statistic.get(u'eta_time', 0)).strftime(u'%H:%M:%S') return {u'tasks': tasks, u'refresh_rate': 5} except Exception as e: logging.exception(e) return {u'errors': [unicode(e)], u'refresh_rate': 30}