Beispiel #1
0
def getLastTaskrun():
    task_id = json.loads( request.data )    
    app_id = pbclient.find_app( short_name = "librasdictionary" )[0].id
    taskruns_for_task_id = pbclient.find_taskruns( app_id, task_id = task_id )
    if len( taskruns_for_task_id ) != 0:
        return jsonify( lastTaskrun = taskruns_for_task_id[-1].info )
    return jsonify( lastTaskrun = None )
Beispiel #2
0
    def verify_task(project_id, task_id):
        task_data = pbclient.get_task(project_id=project_id, task_id=task_id)

        taskruns = pbclient.find_taskruns(project_id=project_id, task_id=task_id)
        taskruns_list = [taskrun.data['info'] for taskrun in taskruns]

        task = AbstractTask.create_task_instance(task_data[0]['info']['type'], **task_data[0])
        task.verify_and_save(taskruns_list)
Beispiel #3
0
    def load(self):
        task_runs = {}

        for t in self.tasks:
            limit = 100
            task_runs[t.id] = []
            taskruns = pbclient.find_taskruns(project_id=self.project_id,
                                              task_id=t.id,
                                              limit=limit,
                                              offset=0,
                                              all=self.all)
            while(len(taskruns) != 0):
                self.check_errors(taskruns)
                task_runs[t.id] += taskruns
                last_id = taskruns[-1].id
                taskruns = pbclient.find_taskruns(
                    project_id=self.project_id,
                    task_id=t.id,
                    limit=limit,
                    last_id=last_id,
                    all=self.all)
        return (task_runs, None)
def getUserTaskRuns( app_id, user_id, current_user_ip ):
    if user_id is None:
        return pbclient.find_taskruns( app_id, user_ip = current_user_ip )        
    return pbclient.find_taskruns( app_id, user_id = user_id )
def getAllTaskRuns( app_id ):
    return pbclient.find_taskruns( app_id )
Beispiel #6
0
        f.writerow(['taskid',
                    'incident id',
                    'incident title',
                    'incident date',
                    'location',
                    'description',
                    'category',
                    'latitude',
                    'longitude',
                    'approved',
                    'verified'])

        while completed_tasks:
            for t in completed_tasks:
                print "Getting answers for task %s: " % t.id
                answers = pbclient.find_taskruns(app.id, task_id=int(t.id))

                if options.average:
                    canonical_answer = copy.deepcopy(answers[0])
                    canonical_answer.task_id = t.id
                    canonical_answer.id = 0
                    canonical_answer.info['category'] = None
                    canonical_answer.info['location'] = None
                    canonical_answer.info['latitude'] = None
                    canonical_answer.info['longitude'] = None
                    # First Categories and sub-categories
                    most_common_category = []
                    categories = []
                    for a in answers:
                        for cat in a.info['category']:
                            categories.append(cat)
Beispiel #7
0
            'username',
            'userid',
            'picture',
            'pictureLink',
            'video',
            'videoLink',
            'location',
            'locationRef',
            'geojson',
            'other',
        ])

        while completed_tasks:
            for t in completed_tasks:
                print t.id
                answers = pbclient.find_taskruns(app.id, task_id=int(t.id))
                for a in answers:
                    line = []

                    if t.id:
                        line.append(t.id)
                    else:
                        line.append("")

                    if t.info['tweetid']:
                        line.append(t.info['tweetid'].encode(
                            'utf-8', 'ignore'))
                    else:
                        line.append("")

                    if t.info['text']: