<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-
from django.views.generic.detail import DetailView
from django.views.generic.list import ListView
from django.contrib.sites.models import get_current_site
from django.shortcuts import get_object_or_404
from django.utils import timezone
from django import template

from opps.articles.utils import set_context_data
from opps.channels.models import Channel


class OppsList(ListView):

    context_object_name = "context"

    def get_context_data(self, **kwargs):
        return set_context_data(self, OppsList, **kwargs)

    @property
    def template_name(self):
        domain_folder = self.type
        if self.site.id > 1:
            domain_folder = "{0}/{1}".format(self.site, self.type)

        return '{0}/{1}.html'.format(domain_folder, self.long_slug)

    @property
    def queryset(self):
        self.site = get_current_site(self.request)
        self.long_slug = None
        if not self.kwargs.get('channel__long_slug'):
            self.article = self.obj.objects.filter(channel__homepage=True,
                                                   site=self.site,<commit_msg>Fix slow query OppsList refs #80<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-
from django.views.generic.detail import DetailView
from django.views.generic.list import ListView
from django.contrib.sites.models import get_current_site
from django.shortcuts import get_object_or_404
from django.utils import timezone
from django import template

from opps.articles.utils import set_context_data
from opps.channels.models import Channel


class OppsList(ListView):

    context_object_name = "context"

    def get_context_data(self, **kwargs):
        return set_context_data(self, OppsList, **kwargs)

    @property
    def template_name(self):
        domain_folder = self.type
        if self.site.id > 1:
            domain_folder = "{0}/{1}".format(self.site, self.type)

        return '{0}/{1}.html'.format(domain_folder, self.long_slug)

    @property
    def queryset(self):
        self.site = get_current_site(self.request)
        self.long_slug = None
        if not self.kwargs.get('channel__long_slug'):
            homepage = Channel.objects.get_homepage(site=self.site)
            self.article = self.obj.objects.filter(channel_name=homepage.name,
                                                   name=homepage.name,
                                                   site=self.site,
{'fraction_non_alphanumeric': 0.0989456609894566, 'fraction_numerical': 0.008110300081103, 'mean_word_length': 2.7492401215805473, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6118202', 'n_tokens_mistral': 727, 'n_tokens_neox': 703, 'n_words': 155}