<commit_before>from django.db.models.signals import post_save
from planet.models import Feed, Post
from actstream import action
from knesset.utils import cannonize, disable_for_loaddata
from knesset.laws.models import VoteAction
from knesset.links.models import Link

@disable_for_loaddata
def connect_feed(sender, created, instance, **kwargs):
    if created:
        t = cannonize(instance.title)
        for m in Member.objects.all():
            if t.rfind(cannonize(m.name)) != -1:
                Link.objects.create(url=instance.url, title = instance.title, content_object=m)
                print u'connected feed to %s' % m
                return
post_save.connect(connect_feed, sender=Feed)

@disable_for_loaddata
def record_vote_action(sender, created, instance, **kwargs):
    if created:
        action.send(instance.member, verb='voted',
                    description=instance.get_type_display(),
                    target = instance.vote,
                    timestamp=instance.vote.time)
post_save.connect(record_vote_action, sender=VoteAction)
<commit_msg>add rss type to feed<->member connection<commit_after>#encoding: utf-8
from django.db.models.signals import post_save
from planet.models import Feed, Post
from actstream import action
from knesset.utils import cannonize, disable_for_loaddata
from knesset.laws.models import VoteAction
from knesset.links.models import Link, LinkType
from knesset.mks.models import Member

@disable_for_loaddata
def connect_feed(sender, created, instance, **kwargs):
    if created:
        t = cannonize(instance.title)
        rss_type = LinkType.objects.get(title='רסס')
        for m in Member.objects.all():
            if t.rfind(cannonize(m.name)) != -1:
                Link.objects.create(url=instance.url, title = instance.title,
                                    content_object=m, link_type=rss_type)
                print u'connected feed to %s' % m
                return
post_save.connect(connect_feed, sender=Feed)

@disable_for_loaddata
def record_vote_action(sender, created, instance, **kwargs):
    if created:
        action.send(instance.member, verb='voted',
                    description=instance.get_type_display(),
                    target = instance.vote,
                    timestamp=instance.vote.time)
post_save.connect(record_vote_action, sender=VoteAction)

{'fraction_non_alphanumeric': 0.09137271568210795, 'fraction_numerical': 0.0012749681257968552, 'mean_word_length': 3.0377358490566038, 'pattern_counts': {'":': 0, '<': 4, '<?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': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3194125', 'n_tokens_mistral': 692, 'n_tokens_neox': 661, 'n_words': 159}