<commit_before># -*- encoding: utf-8 -*-
from urllib import urlencode

from django.http import HttpResponse
from django.conf import settings

from opps.articles.models import Post
from facepy import GraphAPI


def test(request):
    posts = Post.objects.all_published().filter(site=settings.SITE_ID)
    # creates a batch facebook request for posts
    token = ('<KEY>'
             '<KEY>'
             '<KEY>')

    f = GraphAPI(token)
    requests = []
    count = 0
    for post in posts.iterator():
        query = urlencode({'query': "SELECT comment_count FROM link_stat "
                           "WHERE url='{}'".format(
                               post.get_http_absolute_url()
                           )})
        data = {
            'method': 'POST',
            'relative_url': 'method/fql.query?' + query,
        }
        requests.append(data)
        count += 1
        if count == 50:
            # undefined name process_requests
            # process_requests(requests)
            pass
    request = f.batch(requests)
    for result in request:
        print result

    return HttpResponse(requests)<commit_msg>Remove test view<commit_after># -*- encoding: utf-8 -*-
{'fraction_non_alphanumeric': 0.10804020100502512, 'fraction_numerical': 0.005025125628140704, 'mean_word_length': 1.928921568627451, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, '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': '6790587', 'n_tokens_mistral': 327, 'n_tokens_neox': 318, 'n_words': 87}