<commit_before>from django.conf import settings
from django.contrib.auth.models import User
from django.core.urlresolvers import reverse_lazy
from django.db import models

from common import fields
from data_import.models import BaseDataFile, DataRetrievalTask

from ..models import BaseStudyUserData


class UserData(BaseStudyUserData):
    user = fields.AutoOneToOneField(User, related_name='go_viral')

    text_name = 'GoViral'
    href_connect = 'http://www.goviralstudy.com/open-humans'
    href_add_data = 'http://www.goviralstudy.com/open-humans'
    href_learn = 'http://goviralstudy.com/'
    retrieval_url = reverse_lazy('studies:go-viral:request-data-retrieval')

    def get_retrieval_params(self):
        # TODO: We assume a single GoViral ID.
        # If true, change GoViralId.user_data to OneToOne?
        # If false, change data processing?
        go_viral_id = (GoViralId.objects.filter(user_data=self)[0].id)

        return {
            'access_token': settings.GO_VIRAL_MANAGEMENT_TOKEN,
            'go_viral_id': go_viral_id
        }

    @property
    def has_key_data(self):
        """
        Return false if key data needed for data retrieval is not present.
        """
        connected = self.is_connected
        if connected:<commit_msg>🐛 id → value for GoViralId<commit_after>from django.conf import settings
from django.contrib.auth.models import User
from django.core.urlresolvers import reverse_lazy
from django.db import models

from common import fields
from data_import.models import BaseDataFile, DataRetrievalTask

from ..models import BaseStudyUserData


class UserData(BaseStudyUserData):
    user = fields.AutoOneToOneField(User, related_name='go_viral')

    text_name = 'GoViral'
    href_connect = 'http://www.goviralstudy.com/open-humans'
    href_add_data = 'http://www.goviralstudy.com/open-humans'
    href_learn = 'http://goviralstudy.com/'
    retrieval_url = reverse_lazy('studies:go-viral:request-data-retrieval')

    def get_retrieval_params(self):
        # TODO: We assume a single GoViral ID.
        # If true, change GoViralId.user_data to OneToOne?
        # If false, change data processing?
        go_viral_id = (GoViralId.objects.filter(user_data=self)[0].value)

        return {
            'access_token': settings.GO_VIRAL_MANAGEMENT_TOKEN,
            'go_viral_id': go_viral_id
        }

    @property
    def has_key_data(self):
        """
        Return false if key data needed for data retrieval is not present.
        """
        connected = self.is_connected
        if connected:
{'fraction_non_alphanumeric': 0.08949416342412451, 'fraction_numerical': 0.0007782101167315176, 'mean_word_length': 3.270764119601329, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6019541', 'n_tokens_mistral': 822, 'n_tokens_neox': 794, 'n_words': 184}