<commit_before>from django.shortcuts import render
from django.http import HttpResponse, HttpResponseNotFound, \
        HttpResponseServerError, HttpResponseRedirect
from django.conf import settings
import json
import requests
from readmore.content.models import *
import django.dispatch
from django.contrib.auth.decorators import login_required

article_read = django.dispatch.Signal(
        providing_args=["user", "category", "article_id", "article"])

def update_feeds(request):
    for category in RSSCategory.objects.all():
        category.update_feed()
    return HttpResponse()

@login_required
def index(request):
    """Return response containing overview of categories and articles."""
    # Only show top categories on the index page
    categories = Category.objects.filter(parent=None)
    articles = []
    for category in categories:
        articles += category.get_articles()
    # Render response
    if request.is_ajax():
        # Return JSON list of categories with their properties
        categories = [{'url': c.get_absolute_url(), 'title': c.title,
            'image': c.image} for c in categories]
        articles = [{'url': a.get_absolute_url(), 'title': a.title,
            'image': a.image} for a in articles]
        return HttpResponse(
                json.dumps({'categories': categories, 'articles': articles}),
                content_type='application/json')
    else:
        # Render HTML of the landing page containing top categories
        return render(request, 'overview.html',{
                "articles": articles,
                "categories": categories})

@login_required
def query(request):
    """Return response containing articles matching the query."""
    # Fetch any subcategories and articles contained in the category.
    articles = []
    for article in Article.objects.all():
        category = article.get_categories()[0]
        articles.append({
            'url': article.get_absolute_url(),
            'title': article.title,<commit_msg>changed all to recent.<commit_after>from django.shortcuts import render
from django.http import HttpResponse, HttpResponseNotFound, \
        HttpResponseServerError, HttpResponseRedirect
from django.conf import settings
import json
import requests
from readmore.content.models import *
import django.dispatch
from django.contrib.auth.decorators import login_required

article_read = django.dispatch.Signal(
        providing_args=["user", "category", "article_id", "article"])

def update_feeds(request):
    for category in RSSCategory.objects.all():
        category.update_feed()
    return HttpResponse()

@login_required
def index(request):
    """Return response containing overview of categories and articles."""
    # Only show top categories on the index page
    categories = Category.objects.filter(parent=None)
    articles = []
    for category in categories:
        articles += category.get_articles()
    # Render response
    if request.is_ajax():
        # Return JSON list of categories with their properties
        categories = [{'url': c.get_absolute_url(), 'title': c.title,
            'image': c.image} for c in categories]
        articles = [{'url': a.get_absolute_url(), 'title': a.title,
            'image': a.image} for a in articles]
        return HttpResponse(
                json.dumps({'categories': categories, 'articles': articles}),
                content_type='application/json')
    else:
        # Render HTML of the landing page containing top categories
        return render(request, 'overview.html',{
                "articles": articles,
                "categories": categories})

@login_required
def query(request):
    """Return response containing articles matching the query."""
    # Fetch any subcategories and articles contained in the category.
    articles = []
    for article in RSSArticle.objects.order_by('-publication_date').all()[:50]:
        category = article.get_categories()[0]
        articles.append({
            'url': article.get_absolute_url(),
            'title': article.title,
{'fraction_non_alphanumeric': 0.10228669781165478, 'fraction_numerical': 0.0009835259404966806, 'mean_word_length': 3.198142414860681, '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': '4119064', 'n_tokens_mistral': 1019, 'n_tokens_neox': 1001, 'n_words': 322}