<commit_before># This file is part of Indico.
# Copyright (C) 2002 - 2015 European Organization for Nuclear Research (CERN).
#
# Indico is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of the
# License, or (at your option) any later version.
#
# Indico is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Indico; if not, see <http://www.gnu.org/licenses/>.

from __future__ import unicode_literals

from indico.core.plugins import plugin_engine
from indico.util.i18n import _

from MaKaC.conference import SessionSlot


def get_vc_plugins():
    """Returns a dict containing the available video conference plugins."""
    from indico.modules.vc import VCPluginMixin

    return {p.service_name: p for p in plugin_engine.get_active_plugins().itervalues()
            if isinstance(p, VCPluginMixin)}


def full_block_id(block):
    return "{}:{}".format(block.session.id, block.id)


def resolve_title(obj):
    if isinstance(obj, SessionSlot):
        return obj.getFullTitle().decode('utf-8')
    else:
        return obj.getTitle().decode('utf-8')


def get_linked_to_description(obj):
    return {
        'event': _('{} (event)'),
        'contribution': _('{} (contribution)'),
        'block': _('{} (session block)'),
    }[obj.link_type.name].format(resolve_title(obj.link_object))


def get_managed_vc_plugins(user):
    """Returns the plugins the user can manage"""
    return [p for p in get_vc_plugins().itervalues() if p.can_manage_vc(user)]<commit_msg>Add helper to find VC rooms<commit_after># This file is part of Indico.
# Copyright (C) 2002 - 2015 European Organization for Nuclear Research (CERN).
#
# Indico is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of the
# License, or (at your option) any later version.
#
# Indico is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Indico; if not, see <http://www.gnu.org/licenses/>.

from __future__ import unicode_literals

from indico.core.db import db
from indico.core.plugins import plugin_engine
from indico.modules.fulltextindexes.models.events import IndexedEvent
from indico.util.i18n import _

from MaKaC.conference import SessionSlot


def get_vc_plugins():
    """Returns a dict containing the available video conference plugins."""
    from indico.modules.vc import VCPluginMixin

    return {p.service_name: p for p in plugin_engine.get_active_plugins().itervalues()
            if isinstance(p, VCPluginMixin)}


def full_block_id(block):
    return "{}:{}".format(block.session.id, block.id)


def resolve_title(obj):
    if isinstance(obj, SessionSlot):
        return obj.getFullTitle().decode('utf-8')
    else:
        return obj.getTitle().decode('utf-8')


def get_linked_to_description(obj):
    return {
        'event': _('{} (event)'),
        'contribution': _('{} (contribution)'),
        'block': _('{} (session block)'),
    }[obj.link_type.name].format(resolve_title(obj.link_object))


def get_managed_vc_plugins(user):
    """Returns the plugins the user can manage"""
    return [p for p in get_vc_plugins().itervalues() if p.can_manage_vc(user)]


def find_vc_rooms(from_dt=None, to_dt=None):
    """Finds VC rooms matching certain criteria

    :param from_dt: earliest event/contribution to include
    :param to_dt: latest event/contribution to include
    """
    from indico.modules.vc.models.vc_rooms import VCRoomEventAssociation
    query = VCRoomEventAssociation.find()
    if from_dt is not None:
        query = (query.join(IndexedEvent, IndexedEvent.id == db.cast(VCRoomEventAssociation.event_id, db.String))
                 .filter(IndexedEvent.start_date >= from_dt))
    for vc_room in query:
        event = vc_room.event
        if to_dt is not None and event.getStartDate() > to_dt:
            continue
        yield vc_room
{'fraction_non_alphanumeric': 0.09856035437430787, 'fraction_numerical': 0.005758582502768549, 'mean_word_length': 3.9033659066232356, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '7117399', 'n_tokens_mistral': 1362, 'n_tokens_neox': 1298, 'n_words': 460}