<commit_before>""" User model wrapper for comment service"""
from six import text_type

import settings
import models
import utils


class User(models.Model):

    accessible_fields = [
        'username', 'follower_ids', 'upvoted_ids', 'downvoted_ids',
        'id', 'external_id', 'subscribed_user_ids', 'children', 'course_id',
        'group_id', 'subscribed_thread_ids', 'subscribed_commentable_ids',
        'subscribed_course_ids', 'threads_count', 'comments_count',
        'default_sort_key', 'name',
    ]

    updatable_fields = ['username', 'external_id', 'default_sort_key', 'name']
    initializable_fields = updatable_fields

    metric_tag_fields = ['course_id']

    base_url = "{prefix}/users".format(prefix=settings.PREFIX)
    default_retrieve_params = {'complete': True}
    type = 'user'

    @classmethod
    def from_django_user(cls, user):
        return cls(id=str(user.id),
                   external_id=str(user.id),
                   username=user.username,
                   name=user.profile.name)

    def read(self, source):
        """
        Calls cs_comments_service to mark thread as read for the user
        """
        params = {'source_type': source.type, 'source_id': source.id}
        utils.perform_request(
            'post',
            _url_for_read(self.id),
            params,
            metric_action='user.read',
            metric_tags=self._metric_tags + ['target.type:{}'.format(source.type)],
        )

    def follow(self, source):
        params = {'source_type': source.type, 'source_id': source.id}
        response = utils.perform_request(
            'post',
            _url_for_subscription(self.id),
            params,<commit_msg>Revert "Annotate comment_client users with "name""<commit_after>""" User model wrapper for comment service"""
from six import text_type

import settings
import models
import utils


class User(models.Model):

    accessible_fields = [
        'username', 'follower_ids', 'upvoted_ids', 'downvoted_ids',
        'id', 'external_id', 'subscribed_user_ids', 'children', 'course_id',
        'group_id', 'subscribed_thread_ids', 'subscribed_commentable_ids',
        'subscribed_course_ids', 'threads_count', 'comments_count',
        'default_sort_key'
    ]

    updatable_fields = ['username', 'external_id', 'default_sort_key']
    initializable_fields = updatable_fields

    metric_tag_fields = ['course_id']

    base_url = "{prefix}/users".format(prefix=settings.PREFIX)
    default_retrieve_params = {'complete': True}
    type = 'user'

    @classmethod
    def from_django_user(cls, user):
        return cls(id=str(user.id),
                   external_id=str(user.id),
                   username=user.username)

    def read(self, source):
        """
        Calls cs_comments_service to mark thread as read for the user
        """
        params = {'source_type': source.type, 'source_id': source.id}
        utils.perform_request(
            'post',
            _url_for_read(self.id),
            params,
            metric_action='user.read',
            metric_tags=self._metric_tags + ['target.type:{}'.format(source.type)],
        )

    def follow(self, source):
        params = {'source_type': source.type, 'source_id': source.id}
        response = utils.perform_request(
            'post',
            _url_for_subscription(self.id),
            params,
{'fraction_non_alphanumeric': 0.12267218445167012, 'fraction_numerical': 0.0, 'mean_word_length': 2.751662971175166, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '1440069', 'n_tokens_mistral': 1016, 'n_tokens_neox': 998, 'n_words': 201}