Skip to content

Commit

Permalink
Fix import_tasks_with_redundancy
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandermendes committed Jul 20, 2018
1 parent 8a317a0 commit d474ffc
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions pybossa_lc/jobs.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# -*- coding: utf8 -*-
"""Jobs module for pybossa-lc."""

import errno
from flask import current_app
from pybossa.jobs import enqueue_job, import_tasks
from pybossa.core import task_repo, project_repo
from socket import error as socket_error

from .analysis.analyst import Analyst

Expand Down Expand Up @@ -57,8 +59,13 @@ def analyse_single(result_id, presenter):
enqueue_job(job)


def import_tasks_with_redundancy(project_id, min_answers, **import_data):
def import_tasks_with_redundancy(project_id, n_answers, **import_data):
"""Import tasks then set redundancy."""
import_tasks(project_id, **import_data)
try:
import_tasks(project_id, **import_data)
except socket_error as serr:
# Because sending emails will fail during development
if serr.errno != errno.ECONNREFUSED:
raise serr
project = project_repo.get(project_id)
task_repo.update_tasks_redundancy(project, min_answers)
task_repo.update_tasks_redundancy(project, int(n_answers))

0 comments on commit d474ffc

Please sign in to comment.