How to use the psiturk.models.Participant.query.order_by function in PsiTurk

To help you get started, we’ve selected a few PsiTurk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github NYUCCL / psiTurk / psiturk / amt_services_wrapper.py View on Github external
def _try_fetch_local_assignment(self, try_this, with_psiturk_status=None):
        '''
        Can accept either an assignment_id or the return of a mturk boto grab...
        '''
        query = Participant.query.order_by(Participant.beginhit.desc())

        if with_psiturk_status:
            query = query.filter(Participant.status == with_psiturk_status)

        if isinstance(try_this, str):  # then assume that it's an assignment_id
            assignment_id = try_this
            query = query.filter(Participant.assignmentid == assignment_id)

        elif isinstance(try_this, dict):  # then assume that it's a return from mturk
            assignment = try_this
            assignment_id = assignment['assignmentId']
            query = query.filter(Participant.workerid == assignment['workerId'])\
                .filter(Participant.assignmentid == assignment_id)
        else:
            raise PsiturkException('Unrecognized `try_this` value-type: {}'.format(type(try_this)))