-
-
Notifications
You must be signed in to change notification settings - Fork 266
/
task_run.py
60 lines (54 loc) · 2.3 KB
/
task_run.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# -*- coding: utf8 -*-
# This file is part of PyBossa.
#
# Copyright (C) 2015 SciFabric LTD.
#
# PyBossa is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# PyBossa is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with PyBossa. If not, see <http://www.gnu.org/licenses/>.
from sqlalchemy import Integer, Text
from sqlalchemy.schema import Column, ForeignKey
from sqlalchemy.dialects.postgresql import JSON
from pybossa.core import db
from pybossa.model import DomainObject, make_timestamp
class TaskRun(db.Model, DomainObject):
'''A run of a given task by a specific user.
'''
__tablename__ = 'task_run'
#: ID of the TaskRun
id = Column(Integer, primary_key=True)
#: UTC timestamp for when TaskRun is delivered to user.
created = Column(Text, default=make_timestamp)
#: Project.id of the project associated with this TaskRun.
project_id = Column(Integer, ForeignKey('project.id'), nullable=False)
#: Task.id of the task associated with this TaskRun.
task_id = Column(Integer, ForeignKey('task.id', ondelete='CASCADE'),
nullable=False)
#: User.id of the user contributing the TaskRun (only if authenticated)
user_id = Column(Integer, ForeignKey('user.id'))
#: User.ip of the user contributing the TaskRun (only if anonymous)
user_ip = Column(Text)
#: UTC timestamp for when TaskRun is saved to DB.
finish_time = Column(Text, default=make_timestamp)
timeout = Column(Integer)
calibration = Column(Integer)
#: External User ID
external_uid = Column(Text)
#: Value of the answer.
info = Column(JSON)
'''General writable field that should be used by clients to record results\
of a TaskRun. Usually a template for this will be provided by Task
For example::
result: {
whatever information should be recorded -- up to task presenter
}
'''