<commit_before>/**
 * Searches for users
 */
Meteor.publish("searchForUsers", function(query, excluded){
  check(query, String)
  check(excluded, Array)
  return Meteor.users.find({username: {$regex: query, $options: 'i'}, _id: {$nin: excluded}}, {fields: {username: 1, roles: 1},limit: 10})
})

/**
 * Gets the specified conversation
 * NOTE: Is not full conversation with all the function
 */
Meteor.publish("conversation", function(conversationId){
  check(conversationId, String)

  if(!this.userId){
    return this.ready()
  }

  //return Meteor.conversations.find({_id: conversationId, deleted: {$exists:false}}, {limit: 1})

  Meteor.publishWithRelations({
      handle: this,
      collection: Meteor.participants,
      options:options,
      filter: {conversationId: conversationId, deleted:{$exists:false}},
      mappings: [{
          key: 'conversationId',
          collection: Meteor.conversations,
          mappings:[{
              key: "conversationId",
              collection: Meteor.participants,
              filter: {userId:{$ne:this.userId}},
              reverse:true,
              mappings:[{
                  key:"userId",
                  collection:Meteor.users,
                  options:{fields:{username:true}}
              }]
          },{
              reverse:true,
              key: "conversationId",
              collection: Meteor.messages,
              options:{limit:1, sort:{date:-1}}
          }]
      }]
  })
})

/**
 * Count all messages in the given conversation
 */
Meteor.methods({
  countMessages:function(conversationId){<commit_msg>:bug: Options fix<commit_after>/**
 * Searches for users
 */
Meteor.publish("searchForUsers", function(query, excluded){
  check(query, String)
  check(excluded, Array)
  return Meteor.users.find({username: {$regex: query, $options: 'i'}, _id: {$nin: excluded}}, {fields: {username: 1, roles: 1},limit: 10})
})

/**
 * Gets the specified conversation
 * NOTE: Is not full conversation with all the function
 */
Meteor.publish("conversation", function(conversationId){
  check(conversationId, String)

  let options = {}

  if(!this.userId){
    return this.ready()
  }

  //return Meteor.conversations.find({_id: conversationId, deleted: {$exists:false}}, {limit: 1})

  Meteor.publishWithRelations({
      handle: this,
      collection: Meteor.participants,
      options: options,
      filter: {conversationId: conversationId, deleted:{$exists:false}},
      mappings: [{
          key: 'conversationId',
          collection: Meteor.conversations,
          mappings:[{
              key: "conversationId",
              collection: Meteor.participants,
              filter: {userId:{$ne:this.userId}},
              reverse:true,
              mappings:[{
                  key:"userId",
                  collection:Meteor.users,
                  options:{fields:{username:true}}
              }]
          },{
              reverse:true,
              key: "conversationId",
              collection: Meteor.messages,
              options:{limit:1, sort:{date:-1}}
          }]
      }]
  })
})

/**
 * Count all messages in the given conversation
 */
Meteor.methods({
  countMessages:function(conversationId){
{'fraction_non_alphanumeric': 0.13894933167547405, 'fraction_numerical': 0.004351880634131178, 'mean_word_length': 2.501632208922742, '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': '1261671', 'n_tokens_mistral': 945, 'n_tokens_neox': 887, 'n_words': 196}