<commit_before>import json

from django.http import HttpResponse
from django.views.generic import ListView

from bulbs.content.models import Contentish, Tagish


def render_json(page):
    data = {'object_list': [obj.to_dict() for obj in page.object_list]}
    return HttpResponse(json.dumps(data), content_type="application/json")


def search_tags(request):
    tags = Tagish.search(request.GET.get('q'))
    tag_data = [tag.name for tag in tags]
    return HttpResponse(json.dumps(tag_data), content_type='application/json')


class ContentListView(ListView):

    tags = []
    types = []
    published = None

    allow_empty = True
    paginate_by = 20
    context_object_name = 'content'
    template_name = None

    renderers = {
        "text/html": "html",
        "application/json": render_json
    }

    def get_renderer(self, request):
        for mime_type in self.renderers:
            pass

    def get_queryset(self):
        tags = self.tags or self.kwargs.get('tags') or self.request.GET.getlist('tag', [])
        types = self.types or self.kwargs.get('types') or self.request.GET.get('type', [])
        published = self.published or self.kwargs.get('published') or self.request.GET.get('published', [])
        return Contentish.search(tags=tags, types=types, published=published)
<commit_msg>Testing'<commit_after>import json

from django.http import HttpResponse
from django.views.generic import ListView

from bulbs.content.models import Contentish, Tagish


def render_json(page):
    data = {'object_list': [obj.to_dict() for obj in page.object_list]}
    return HttpResponse(json.dumps(data), content_type="application/json")


def search_tags(request):
    tags = Tagish.search(request.GET.get('q'))
    tag_data = [tag.name for tag in tags]
    return HttpResponse(json.dumps(tag_data), content_type='application/json')


class ContentListView(ListView):

    tags = []
    types = []
    published = None

    allow_empty = True
    paginate_by = 20
    context_object_name = 'content'
    template_name = None

    renderers = {
        "text/html": "html",
        "application/json": render_json
    }

    def get_renderer(self, request):
        for mime_type in self.renderers:
            pass

    def get_queryset(self):
        tags = self.tags or self.kwargs.get('tags') or self.request.GET.getlist('tag', [])
        types = self.types or self.kwargs.get('types') or self.request.GET.getlist('type', [])
        feature_types = self.types or self.kwargs.get('feature_types') or self.request.GET.getlist('feature_type', [])
        published = self.published or self.kwargs.get('published') or self.request.GET.get('published', [])
        return Contentish.search(tags=tags, feature_types=feature_types, types=types, published=published)

{'fraction_non_alphanumeric': 0.12387791741472172, 'fraction_numerical': 0.001436265709156194, 'mean_word_length': 3.552287581699346, 'pattern_counts': {'":': 4, '<': 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': '2934384', 'n_tokens_mistral': 859, 'n_tokens_neox': 834, 'n_words': 189}