<commit_before>from datetime import datetime
import logging

from pylons import request, response, tmpl_context as c
from pylons.controllers.util import redirect
from pylons.decorators import validate

from adhocracy import model
from adhocracy.controllers.event import EventController
from adhocracy.lib import helpers as h
from adhocracy.lib.auth import require
from adhocracy.lib.base import BaseController
from adhocracy.lib.static import StaticPage
from adhocracy.lib.templating import render
from adhocracy.lib.util import get_entity_or_abort

from proposal import ProposalFilterForm


log = logging.getLogger(__name__)


class RootController(BaseController):

    @validate(schema=ProposalFilterForm(), post_only=False, on_get=True)
    def index(self, format='html'):
        require.proposal.index()
        if c.instance:
            redirect(h.entity_url(c.instance))

        c.instances = model.Instance.all()[:5]
        c.page = StaticPage('index')

        #query = self.form_result.get('proposals_q')
        #proposals = libsearch.query.run(query,
        #                                entity_type=model.Proposal)[:10]
        c.milestones = model.Milestone.all()
        #c.proposals_pager = pager.proposals(proposals)
        #c.proposals = c.proposals_pager.here()
        c.stats_global = {
                "members": model.User.all_q().count(),
                "comments": model.Comment.all_q().count(),
                "proposals": model.Proposal.all_q().count(),
                "votes": model.Vote.all_q().count(),
            }

        if format == 'rss':
            return EventController().all(format='rss')

        return render('index.html')

    #@RequireInstance
    def dispatch_delegateable(self, id):
        dgb = get_entity_or_abort(model.Delegateable, id,
                                  instance_filter=False)
        redirect(h.entity_url(dgb))<commit_msg>Option adhocracy.startpage.instances.list_length in adhocracy.ini changes the number of instances looked-up in root.py. Default is 5.<commit_after>from datetime import datetime
import logging

from paste.deploy.converters import asint
from pylons import request, response, tmpl_context as c, config
from pylons.controllers.util import redirect
from pylons.decorators import validate

from adhocracy import model
from adhocracy.controllers.event import EventController
from adhocracy.lib import helpers as h
from adhocracy.lib.auth import require
from adhocracy.lib.base import BaseController
from adhocracy.lib.static import StaticPage
from adhocracy.lib.templating import render
from adhocracy.lib.util import get_entity_or_abort

from proposal import ProposalFilterForm


log = logging.getLogger(__name__)


class RootController(BaseController):

    @validate(schema=ProposalFilterForm(), post_only=False, on_get=True)
    def index(self, format='html'):
        require.proposal.index()
        if c.instance:
            redirect(h.entity_url(c.instance))

        instances_in_root = asint(config.get('adhocracy.startpage.instances.list_length', 5))
        if instances_in_root > 0:
            c.instances = model.Instance.all(limit=instances_in_root)
        elif instances_in_root == -1:
            c.instances = model.Instance.all()

        c.page = StaticPage('index')

        #query = self.form_result.get('proposals_q')
        #proposals = libsearch.query.run(query,
        #                                entity_type=model.Proposal)[:10]
        c.milestones = model.Milestone.all()
        #c.proposals_pager = pager.proposals(proposals)
        #c.proposals = c.proposals_pager.here()
        c.stats_global = {
                "members": model.User.all_q().count(),
                "comments": model.Comment.all_q().count(),
                "proposals": model.Proposal.all_q().count(),
                "votes": model.Vote.all_q().count(),
            }

        if format == 'rss':
            return EventController().all(format='rss')

        return render('index.html')

    #@RequireInstance
    def dispatch_delegateable(self, id):
        dgb = get_entity_or_abort(model.Delegateable, id,
                                  instance_filter=False)
        redirect(h.entity_url(dgb))
{'fraction_non_alphanumeric': 0.10078254683424236, 'fraction_numerical': 0.0021342186388427793, 'mean_word_length': 2.8768382352941178, 'pattern_counts': {'":': 8, '<': 3, '<?xml version=': 0, '>': 4, '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': '2108099', 'n_tokens_mistral': 1279, 'n_tokens_neox': 1216, 'n_words': 257}