<commit_before>package gki.chat

import groovy.util.logging.Slf4j
import groovy.json.JsonSlurper
import grails.converters.JSON

import org.springframework.messaging.handler.annotation.MessageMapping

@Slf4j
class ChatController {

  def chatService
  def chatBotDefaultService
  def feedCrawlerService

  String thisUserName = ''
  
  def jsonSlurper = new JsonSlurper()
  
  def index() {}

  @MessageMapping("/addUser")
  protected void addUser(ChatMessage message) {
    log.info "addUser: ${message}"
    thisUserName = message.username
    chatService.addUser(message.username, message.chatroom)

    chatService.sendLog(message)
    chatService.sendUserList()
  }


  @MessageMapping("/updateUser")
  protected void updateUser(ChatMessage message) {
    log.info "updateUser: ${message}"
    thisUserName = message.username
    chatService.addUser(message.username, message.chatroom)

    chatService.sendUserList()
  }


  @MessageMapping("/log")
  protected String sendLog(ChatMessage message) {
    log.info "log: ${message}"
    chatService.sendLog(message)
  }

  
  @MessageMapping("/message")
  protected String receiveMessage(ChatMessage message) {
    log.info "message: ${message}"
    chatService.receiveMessage(message)
  }
  

  @MessageMapping("/tempMessage")
  protected String receiveTempMessage(ChatMessage message) {
    chatService.receiveTempMessage(message)
  }
  

  @MessageMapping("/heartbeat")
  protected String heartbeatCount(ChatMessage message) {
    log.debug "heartbeat: ${message}"
    chatService.heartbeatCount(message)
  }


  def countMessages() {
    def day = params.day.replace('/', '-')
    def counted = ChatMessage.countByChatroomAndDate(params.room, day)
    log.info "room: ${params.room}, day: ${day}, count: ${counted}"

    def result = [:]
    result << ['count': counted]
    result << ['day': params.day]
    
    render result as JSON
  }
  
<commit_msg>comment out debug log.<commit_after>package gki.chat

import groovy.util.logging.Slf4j
import groovy.json.JsonSlurper
import grails.converters.JSON

import org.springframework.messaging.handler.annotation.MessageMapping

@Slf4j
class ChatController {

  def chatService
  def chatBotDefaultService
  def feedCrawlerService

  String thisUserName = ''
  
  def jsonSlurper = new JsonSlurper()
  
  def index() {}

  @MessageMapping("/addUser")
  protected void addUser(ChatMessage message) {
    log.info "addUser: ${message}"
    thisUserName = message.username
    chatService.addUser(message.username, message.chatroom)

    chatService.sendLog(message)
    chatService.sendUserList()
  }


  @MessageMapping("/updateUser")
  protected void updateUser(ChatMessage message) {
    log.info "updateUser: ${message}"
    thisUserName = message.username
    chatService.addUser(message.username, message.chatroom)

    chatService.sendUserList()
  }


  @MessageMapping("/log")
  protected String sendLog(ChatMessage message) {
    log.info "log: ${message}"
    chatService.sendLog(message)
  }

  
  @MessageMapping("/message")
  protected String receiveMessage(ChatMessage message) {
    log.info "message: ${message}"
    chatService.receiveMessage(message)
  }
  

  @MessageMapping("/tempMessage")
  protected String receiveTempMessage(ChatMessage message) {
    chatService.receiveTempMessage(message)
  }
  

  @MessageMapping("/heartbeat")
  protected String heartbeatCount(ChatMessage message) {
    log.debug "heartbeat: ${message}"
    chatService.heartbeatCount(message)
  }


  def countMessages() {
    def day = params.day.replace('/', '-')
    def counted = ChatMessage.countByChatroomAndDate(params.room, day)
    //    log.info "room: ${params.room}, day: ${day}, count: ${counted}"

    def result = [:]
    result << ['count': counted]
    result << ['day': params.day]
    
    render result as JSON
  }
  

{'fraction_non_alphanumeric': 0.11493354182955434, 'fraction_numerical': 0.0010424811050299713, 'mean_word_length': 4.030144167758847, 'pattern_counts': {'":': 0, '<': 11, '<?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': '3016806', 'n_tokens_mistral': 1178, 'n_tokens_neox': 1133, 'n_words': 233}