<commit_before>import grequests
import string
import logging

from django.core.urlresolvers import reverse

from django.http import HttpResponseRedirect

from django.shortcuts import render

from django.views.decorators.cache import cache_control
from django.views.decorators.http import require_http_methods

from core.api.resources import FileMetadata
from core.api.resources import Comment
from core.api.resources import Profile
from core.api.resources import Attachment
from core.api.resources import response_list_to_dict
from core.api.resources import ProfileList
from core.api.resources import Search
from core.api.resources import Site
from core.api.exceptions import APIException

from core.forms.forms import ProfileEdit

from core.views import build_pagination_links
from core.views import require_authentication
from core.views import respond_with_error


logger = logging.getLogger('profiles.views')
edit_form = ProfileEdit
form_template = 'forms/profile.html'
single_template = 'profile.html'
list_template = 'profiles.html'


@require_http_methods(['GET',])
@cache_control(must_revalidate=True, max_age=0)
def single(request, profile_id):
    """
    Display a single profile by ID.
    """

    # Fetch profile details.
    profile_url, params, headers = Profile.build_request(request.get_host(), profile_id)
    request.view_requests.append(grequests.get(profile_url, params=params, headers=headers))

    # Fetch items created by this profile.
    search_q = 'type:microcosm type:conversation type:event type:comment authorId:%s' % profile_id
    search_params = {'limit': 5, 'q': search_q, 'sort': 'date'}
    search_url, params, headers = Search.build_request(request.get_host(), search_params,
        access_token=request.access_token)
    request.view_requests.append(grequests.get(search_url, params=params, headers=headers))

    try:
        responses = response_list_to_dict(grequests.map(request.view_requests))
    except APIException as exc:
        return respond_with_error(request, exc)

    user = Profile(responses[request.whoami_url], summary=False) if request.whoami_url else None
    profile = Profile(responses[profile_url], summary=False)

    view_data = {
        'user': user,
        'content': profile,
        'item_type': 'profile',
        'site': Site(responses[request.site_url]),
        'search': Search.from_api_response(responses[search_url]),
        'site_section': 'people'
    }
    return render(request, single_template, view_data)

<commit_msg>Removed microcosms from profile page recent activity, expanded to 10 items<commit_after>import grequests
import string
import logging

from django.core.urlresolvers import reverse

from django.http import HttpResponseRedirect

from django.shortcuts import render

from django.views.decorators.cache import cache_control
from django.views.decorators.http import require_http_methods

from core.api.resources import FileMetadata
from core.api.resources import Comment
from core.api.resources import Profile
from core.api.resources import Attachment
from core.api.resources import response_list_to_dict
from core.api.resources import ProfileList
from core.api.resources import Search
from core.api.resources import Site
from core.api.exceptions import APIException

from core.forms.forms import ProfileEdit

from core.views import build_pagination_links
from core.views import require_authentication
from core.views import respond_with_error


logger = logging.getLogger('profiles.views')
edit_form = ProfileEdit
form_template = 'forms/profile.html'
single_template = 'profile.html'
list_template = 'profiles.html'


@require_http_methods(['GET',])
@cache_control(must_revalidate=True, max_age=0)
def single(request, profile_id):
    """
    Display a single profile by ID.
    """

    # Fetch profile details.
    profile_url, params, headers = Profile.build_request(request.get_host(), profile_id)
    request.view_requests.append(grequests.get(profile_url, params=params, headers=headers))

    # Fetch items created by this profile.
    search_q = 'type:conversation type:event type:huddle type:comment authorId:%s' % profile_id
    search_params = {'limit': 10, 'q': search_q, 'sort': 'date'}
    search_url, params, headers = Search.build_request(request.get_host(), search_params,
        access_token=request.access_token)
    request.view_requests.append(grequests.get(search_url, params=params, headers=headers))

    try:
        responses = response_list_to_dict(grequests.map(request.view_requests))
    except APIException as exc:
        return respond_with_error(request, exc)

    user = Profile(responses[request.whoami_url], summary=False) if request.whoami_url else None
    profile = Profile(responses[profile_url], summary=False)

    view_data = {
        'user': user,
        'content': profile,
        'item_type': 'profile',
        'site': Site(responses[request.site_url]),
        'search': Search.from_api_response(responses[search_url]),
        'site_section': 'people'
    }
    return render(request, single_template, view_data)


{'fraction_non_alphanumeric': 0.09055040441901756, 'fraction_numerical': 0.0013809429867824028, 'mean_word_length': 5.0, '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': '3259136', 'n_tokens_mistral': 1459, 'n_tokens_neox': 1436, 'n_words': 364}