<commit_before>from django.contrib.syndication.views import Feed
from django.core.cache import cache
from django.utils import timezone
from django.utils.feedgenerator import Atom1Feed
from django.utils.http import urlquote

from judge.math_parser import MathHTMLParser, MATHTEX_CGI
from judge.models import Comment, BlogPost, Problem
from markdown_trois import markdown


class FeedMath(MathHTMLParser):
    def inline_math(self, math):
        return (r'<img class="tex-image" src="%s?\textstyle %s" alt="%s"/>' %
                (MATHTEX_CGI, urlquote(math), math))

    def display_math(self, math):
        return (r'<img class="tex-image" src="%s?\displaystyle %s" alt="%s"/>' %
                (MATHTEX_CGI, urlquote(math), math))

class ProblemFeed(Feed):
    title = 'Recently added DMOJ problems'
    link = '/'
    description = 'The latest problems added on the Don Mills Online Judge website'

    def items(self):
        return Problem.objects.filter(is_public=True).order_by('-id')[:25]

    def item_title(self, problem):
        return problem.name

    def item_description(self, problem):
        key = 'problem_feed:%d' % problem.id
        desc = cache.get(key)
        if desc is None:
            desc = FeedMath.convert(markdown(problem.description, 'problem'))[:500] + '...'
            cache.set(key, desc, 86400)
        return desc

class AtomProblemFeed(ProblemFeed):
    feed_type = Atom1Feed
    subtitle = ProblemFeed.description

class CommentFeed(Feed):
    title = 'Latest DMOJ comments'
    link = '/'
    description = 'The latest comments on the Don Mills Online Judge website'

    def items(self):
        return Comment.objects.order_by('-time')[:25]<commit_msg>Problem date in feed.<commit_after>from django.contrib.syndication.views import Feed
from django.core.cache import cache
from django.utils import timezone
from django.utils.feedgenerator import Atom1Feed
from django.utils.http import urlquote

from judge.math_parser import MathHTMLParser, MATHTEX_CGI
from judge.models import Comment, BlogPost, Problem
from markdown_trois import markdown


class FeedMath(MathHTMLParser):
    def inline_math(self, math):
        return (r'<img class="tex-image" src="%s?\textstyle %s" alt="%s"/>' %
                (MATHTEX_CGI, urlquote(math), math))

    def display_math(self, math):
        return (r'<img class="tex-image" src="%s?\displaystyle %s" alt="%s"/>' %
                (MATHTEX_CGI, urlquote(math), math))


class ProblemFeed(Feed):
    title = 'Recently added DMOJ problems'
    link = '/'
    description = 'The latest problems added on the Don Mills Online Judge website'

    def items(self):
        return Problem.objects.filter(is_public=True).order_by('-date', '-id')[:25]

    def item_title(self, problem):
        return problem.name

    def item_description(self, problem):
        key = 'problem_feed:%d' % problem.id
        desc = cache.get(key)
        if desc is None:
            desc = FeedMath.convert(markdown(problem.description, 'problem'))[:500] + '...'
            cache.set(key, desc, 86400)
        return desc

    def item_pubdate(self, problem):
        return problem.date


class AtomProblemFeed(ProblemFeed):
    feed_type = Atom1Feed
    subtitle = ProblemFeed.description


class CommentFeed(Feed):
    title = 'Latest DMOJ comments'
    link = '/'
    description = 'The latest comments on the Don Mills Online Judge website'

    def items(self):
        return Comment.objects.order_by('-time')[:25]
{'fraction_non_alphanumeric': 0.11397479954180985, 'fraction_numerical': 0.008018327605956471, 'mean_word_length': 3.3499377334993774, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '7077966', 'n_tokens_mistral': 1093, 'n_tokens_neox': 1027, 'n_words': 284}