<commit_before># -*- coding: utf-8 -*-
import logging

from pircel import model
from tornado import websocket
import tornado.web

from possel import auth


logger = logging.getLogger(__name__)


class ResourcePusher(websocket.WebSocketHandler):
    def get_current_user(self):
        token = self.get_secure_cookie('token')
        if token is None:
            return None
        return auth.get_user_by_token(token)

    @tornado.web.asynchronous
    def get(self, *args, **kwargs):
        if not self.get_current_user():
            self.set_status(401)
            self.finish('Unauthorized.')
            return
        super(ResourcePusher, self).get(*args, **kwargs)

    def check_origin(self, origin):
        return True

    def send_last_line_id(self):
        try:
            line = model.IRCLineModel.select().order_by(-model.IRCLineModel.id).limit(1)[0]
        except IndexError:
            self.write_message({'type': 'last_line', 'line': -1})
        else:
            self.write_message({'type': 'last_line', 'line': line.id})

    def send_line_id(self, _, line, server):
        self.write_message({'type': 'line', 'line': line.id})

    def send_buffer_id(self, _, buffer, server):
        self.write_message({'type': 'buffer', 'buffer': buffer.id, 'server': server.id})

    def send_user_id(self, _, user, server):
        self.write_message({'type': 'user', 'user': user.id, 'server': server.id})

    def send_server_id(self, _, server):
        self.write_message({'type': 'server', 'server': server.id})

    def send_membership(self, _, membership, user, buffer):
        self.write_message({'type': 'membership', 'membership': membership.id, 'user': user.id, 'buffer': buffer.id})

    def send_deleted_membership(self, _, membership):<commit_msg>Send buffer id with line<commit_after># -*- coding: utf-8 -*-
import logging

from pircel import model
from tornado import websocket
import tornado.web

from possel import auth


logger = logging.getLogger(__name__)


class ResourcePusher(websocket.WebSocketHandler):
    def get_current_user(self):
        token = self.get_secure_cookie('token')
        if token is None:
            return None
        return auth.get_user_by_token(token)

    @tornado.web.asynchronous
    def get(self, *args, **kwargs):
        if not self.get_current_user():
            self.set_status(401)
            self.finish('Unauthorized.')
            return
        super(ResourcePusher, self).get(*args, **kwargs)

    def check_origin(self, origin):
        return True

    def send_last_line_id(self):
        try:
            line = model.IRCLineModel.select().order_by(-model.IRCLineModel.id).limit(1)[0]
        except IndexError:
            self.write_message({'type': 'last_line', 'line': -1})
        else:
            self.write_message({'type': 'last_line', 'line': line.id})

    def send_line_id(self, _, line, server):
        self.write_message({'type': 'line', 'line': line.id, 'buffer': line.buffer.id})

    def send_buffer_id(self, _, buffer, server):
        self.write_message({'type': 'buffer', 'buffer': buffer.id, 'server': server.id})

    def send_user_id(self, _, user, server):
        self.write_message({'type': 'user', 'user': user.id, 'server': server.id})

    def send_server_id(self, _, server):
        self.write_message({'type': 'server', 'server': server.id})

    def send_membership(self, _, membership, user, buffer):
        self.write_message({'type': 'membership', 'membership': membership.id, 'user': user.id, 'buffer': buffer.id})

    def send_deleted_membership(self, _, membership):
{'fraction_non_alphanumeric': 0.14273812829769508, 'fraction_numerical': 0.0038878089419605664, 'mean_word_length': 3.1641618497109825, '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': '3340609', 'n_tokens_mistral': 1136, 'n_tokens_neox': 1111, 'n_words': 247}