예제 #1
0
class ResponsePI(ModelBase):
    """Holds remote-troubleshooting and other product data."""
    opinion = models.ForeignKey(Response)
    data = JSONObjectField()

    def __unicode__(self):
        return unicode(self.id)
예제 #2
0
class ResponseContext(ModelBase):
    """Holds context data we were sent as a JSON blob."""

    opinion = models.ForeignKey(Response)
    data = JSONObjectField()

    def __unicode__(self):
        return unicode(self.id)
예제 #3
0
class Record(models.Model):
    """Defines an audit record for something that happened in translations"""

    TYPE_CHOICES = [
        (RECORD_INFO, RECORD_INFO),
        (RECORD_ERROR, RECORD_ERROR),
    ]

    # What app does this apply to
    app = models.CharField(max_length=50)

    # What component was running (e.g. "gengo-machine", "dennis", ...)
    src = models.CharField(max_length=50)

    # The type of this message (e.g. "info", "error", ...)
    type = models.CharField(choices=TYPE_CHOICES, max_length=20)

    # What happened to create this entry (e.g. "guess-language",
    # "translate", ...)
    action = models.CharField(max_length=20)

    # The message details in English (e.g. "unknown language",
    # "unsupported language", ...)
    msg = models.CharField(max_length=255)

    # Generic foreign key to the object this record is about if any
    content_type = models.ForeignKey(ContentType, null=True)
    object_id = models.PositiveIntegerField(null=True)
    content_object = GenericForeignKey()

    # When this log entry was created
    created = models.DateTimeField(default=datetime.now)

    # Any metadata related to this entry in the form of a Python dict which
    # is stored as a JSON object
    metadata = JSONObjectField()

    objects = RecordManager()

    def __unicode__(self):
        return u'<Record {key} {msg}>'.format(
            key=u':'.join([self.src, self.type, self.action]),
            msg=self.msg)
예제 #4
0
class Answer(ModelBase):
    """A survey answer.

    When a user is selected to be asked a survey question, we'll
    capture their answer, contextual data and their progression
    through the survey flow in an Answer.

    .. Note::

       This data contains personally identifiable information and so
       it can **never** be made publicly available.

    """
    # The version of the experiment addon.
    experiment_version = models.CharField(max_length=50)

    # The version of the HTTP POST packet shape. This allows us to
    # change how some of the values in the packet are calculated and
    # distinguish between different iterations of answers for the same
    # survey.
    response_version = models.IntegerField()

    # Timestamp of the last update to this Answer.
    updated_ts = models.BigIntegerField(default=0)

    # uuids of things. person_id can have multiple flows where each
    # flow represents a different time the person was asked to
    # participate in the survey. It's possible the question text could
    # change. We capture it here to make it easier to do db analysis
    # without requiring extra maintenance (e.g. updating a Question
    # table).
    person_id = models.CharField(max_length=50)
    survey_id = models.ForeignKey(
        Survey, db_column='survey_id', to_field='name', db_index=True)
    flow_id = models.CharField(max_length=50)

    # The id, text and variation of the question being asked.
    question_id = models.CharField(max_length=50)
    question_text = models.TextField()
    variation_id = models.CharField(max_length=100)

    # score out of max_score. Use null for no value.
    score = models.FloatField(null=True, blank=True)
    max_score = models.FloatField(null=True, blank=True)

    # These are the timestamps the user performed various actions in
    # the flow. Use 0 for no value.
    flow_began_ts = models.BigIntegerField(default=0)
    flow_offered_ts = models.BigIntegerField(default=0)
    flow_voted_ts = models.BigIntegerField(default=0)
    flow_engaged_ts = models.BigIntegerField(default=0)

    # Data about the user's browser. Use '' for no value.
    platform = models.CharField(max_length=50, blank=True, default=u'')
    channel = models.CharField(max_length=50, blank=True, default=u'')
    version = models.CharField(max_length=50, blank=True, default=u'')
    locale = models.CharField(max_length=50, blank=True, default=u'')
    build_id = models.CharField(max_length=50, blank=True, default=u'')
    partner_id = models.CharField(max_length=50, blank=True, default=u'')

    # Data about the user's profile. Use null for no value.
    profile_age = models.BigIntegerField(null=True, blank=True)

    # Data about the profile usage, addons and extra stuff. Use {} for
    # no value.
    profile_usage = JSONObjectField(blank=True)
    addons = JSONObjectField(blank=True)

    # This will likely include data like "crashiness", "search
    # settings" and any "weird settings". This will have some context
    # surrounding the rating score.
    extra = JSONObjectField(blank=True)

    # Whether or not this is test data.
    is_test = models.BooleanField(default=False, blank=True)

    received_ts = models.DateTimeField(
        auto_now=True,
        help_text=u'Time the server received the last update packet')

    class Meta:
        unique_together = (
            ('person_id', 'survey_id', 'flow_id'),
        )
        index_together = [
            ('person_id', 'survey_id', 'flow_id'),
        ]

    def __unicode__(self):
        return '%s: %s %s %s' % (
            self.id, self.survey_id, self.flow_id, self.updated_ts)