<commit_before>Meteor.publish(null, function () {
  if (this.userId) {
    return Meteor.users.find({ _id: this.userId }, { fields: { biography: 1, followingIds: 1 } });
  }
});

Meteor.publishComposite('posts.all', function (query, limit) {
  check(query, String);
  check(limit, Number);

  if (this.userId) {
    return {
      find: () => {
        let parameters = {};
        if (query) {
          parameters.find =  { $text: { $search: query } };
          parameters.options = {
            fields: { score: { $meta: 'textScore' } },
              sort: { score: { $meta: 'textScore' } },
              limit: limit
          };
        }
        else {
          parameters.find = {};
          parameters.options = { sort: { createdAt: -1 }, limit: limit };
        }
        Counts.publish(this, 'posts.all', Posts.find(parameters.find), { noReady: true });
        return Posts.find(parameters.find, parameters.options);
      },
      children: [
        {
          find: (post) => {
            return Meteor.users.find({ _id: post.authorId }, { fields: { emails: 1, username: 1 } });
          }
        }
      ]
    }
  } else {
    return [];
  }
});

Meteor.publishComposite('users.profile', function (_id, limit) {
  check(_id, String);
  check(limit, Number);

  if (this.userId) {
    return {
      find: () => {
        return Meteor.users.find({ _id: _id });
      },
      children: [
        {
          find: (user) => {
            Counts.publish(this, 'posts.all', Posts.find({ authorId: user._id }), { noReady: true });
            return Posts.find({ authorId: user._id }, { sort: { createdAt: -1 }, limit: limit });
          }
        }
      ]
    }
  } else {
    return [];
  }
});

Meteor.publish('users.all', function (query, limit) {
  check(query, String);
  check(limit, Number);

  if (this.userId) {
    if (query) {
      Counts.publish(this, 'users.all', Meteor.users.find(), { noReady:true });
      return Meteor.users.find(
        {
          $text: {
            $search: query
          }
        },
        {
          fields: {
            score: {
              $meta: 'textScore'
            }
          },
          sort: {
            score: {
              $meta: 'textScore'
            }
          },
          limit: limit
        }
      );
    } else {
      Counts.publish(this, 'users.all', Meteor.users.find(), { noReady: true });<commit_msg>Fix a missing query option in users.all publication<commit_after>Meteor.publish(null, function () {
  if (this.userId) {
    return Meteor.users.find({ _id: this.userId }, { fields: { biography: 1, followingIds: 1 } });
  }
});

Meteor.publishComposite('posts.all', function (query, limit) {
  check(query, String);
  check(limit, Number);

  if (this.userId) {
    return {
      find: () => {
        let parameters = {};
        if (query) {
          parameters.find =  { $text: { $search: query } };
          parameters.options = {
            fields: { score: { $meta: 'textScore' } },
              sort: { score: { $meta: 'textScore' } },
              limit: limit
          };
        }
        else {
          parameters.find = {};
          parameters.options = { sort: { createdAt: -1 }, limit: limit };
        }
        Counts.publish(this, 'posts.all', Posts.find(parameters.find), { noReady: true });
        return Posts.find(parameters.find, parameters.options);
      },
      children: [
        {
          find: (post) => {
            return Meteor.users.find({ _id: post.authorId }, { fields: { emails: 1, username: 1 } });
          }
        }
      ]
    }
  } else {
    return [];
  }
});

Meteor.publishComposite('users.profile', function (_id, limit) {
  check(_id, String);
  check(limit, Number);

  if (this.userId) {
    return {
      find: () => {
        return Meteor.users.find({ _id: _id });
      },
      children: [
        {
          find: (user) => {
            Counts.publish(this, 'posts.all', Posts.find({ authorId: user._id }), { noReady: true });
            return Posts.find({ authorId: user._id }, { sort: { createdAt: -1 }, limit: limit });
          }
        }
      ]
    }
  } else {
    return [];
  }
});

Meteor.publish('users.all', function (query, limit) {
  check(query, String);
  check(limit, Number);

  if (this.userId) {
    if (query) {
      Counts.publish(this, 'users.all', Meteor.users.find({$text: {$search: query}}), { noReady:true });
      return Meteor.users.find(
        {
          $text: {
            $search: query
          }
        },
        {
          fields: {
            score: {
              $meta: 'textScore'
            }
          },
          sort: {
            score: {
              $meta: 'textScore'
            }
          },
          limit: limit
        }
      );
    } else {
      Counts.publish(this, 'users.all', Meteor.users.find(), { noReady: true });
{'fraction_non_alphanumeric': 0.16356192425793245, 'fraction_numerical': 0.0024564994882292734, 'mean_word_length': 1.6655755591925805, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '2935410', 'n_tokens_mistral': 1537, 'n_tokens_neox': 1504, 'n_words': 305}