<commit_before># -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals

import calendar
import json
import six

from django.core.paginator import Paginator, PageNotAnInteger, EmptyPage
from django.conf import settings
from django.http import HttpResponsePermanentRedirect, HttpResponse
from django.template.response import TemplateResponse
from django.utils.decorators import method_decorator
from django.utils.translation import ugettext_lazy as _
from django.views.decorators.csrf import csrf_exempt
from smartmin.views import SmartReadView, SmartTemplateView

from dash.stories.models import Story
from ureport.countries.models import CountryAlias
from ureport.jobs.models import JobSource
from ureport.polls.models import Poll, PollQuestion
from dash.categories.models import Category
from dash.orgs.models import Org
from ureport.news.models import Video, NewsItem
import pycountry
from ureport.utils import get_linked_orgs, get_global_count


class IndexView(SmartTemplateView):
    template_name = 'public/index.html'

    def get_context_data(self, **kwargs):
        context = super(IndexView, self).get_context_data(**kwargs)

        org = self.request.org
        context['org'] = org

        latest_poll = Poll.get_main_poll(org)
        context['latest_poll'] = latest_poll
        if context['latest_poll']:
            context['trending_words'] = latest_poll.get_trending_words()

        brick_poll_ids = Poll.get_brick_polls_ids(org)
        context['recent_polls'] = Poll.objects.filter(id__in=brick_poll_ids)

        context['stories'] = Story.objects.filter(org=org, is_active=True, featured=True).order_by('-created_on')<commit_msg>Add order by created on desc on recent polls<commit_after># -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals

import calendar
import json
import six

from django.core.paginator import Paginator, PageNotAnInteger, EmptyPage
from django.conf import settings
from django.http import HttpResponsePermanentRedirect, HttpResponse
from django.template.response import TemplateResponse
from django.utils.decorators import method_decorator
from django.utils.translation import ugettext_lazy as _
from django.views.decorators.csrf import csrf_exempt
from smartmin.views import SmartReadView, SmartTemplateView

from dash.stories.models import Story
from ureport.countries.models import CountryAlias
from ureport.jobs.models import JobSource
from ureport.polls.models import Poll, PollQuestion
from dash.categories.models import Category
from dash.orgs.models import Org
from ureport.news.models import Video, NewsItem
import pycountry
from ureport.utils import get_linked_orgs, get_global_count


class IndexView(SmartTemplateView):
    template_name = 'public/index.html'

    def get_context_data(self, **kwargs):
        context = super(IndexView, self).get_context_data(**kwargs)

        org = self.request.org
        context['org'] = org

        latest_poll = Poll.get_main_poll(org)
        context['latest_poll'] = latest_poll
        if context['latest_poll']:
            context['trending_words'] = latest_poll.get_trending_words()

        brick_poll_ids = Poll.get_brick_polls_ids(org)
        context['recent_polls'] = Poll.objects.filter(id__in=brick_poll_ids).order_by('-created_on')

        context['stories'] = Story.objects.filter(org=org, is_active=True, featured=True).order_by('-created_on')
{'fraction_non_alphanumeric': 0.08129143845488614, 'fraction_numerical': 0.0005765350245027386, 'mean_word_length': 5.034782608695652, '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': '6683918', 'n_tokens_mistral': 1009, 'n_tokens_neox': 983, 'n_words': 247}