<commit_before>import PublicationUtils from 'meteor/utilities:smart-publications'
import Posts from "meteor/nova:posts"
import Users from "meteor/nova:users"

// check if user can subscribe to post
const canSubscribe = user => Users.canDo(user, "posts.new");

Users.addField({
  fieldName: 'telescope.subscribedItems',
  fieldSchema: {
    type: Object,
    optional: true,
    blackbox: true,
    autoform: {
      omit: true
    }
  }
});

PublicationUtils.addToFields(
  Users.publishedFields.list, ["telescope.subscribedItems"]
)

Posts.addField(
  {
    fieldName: 'subscribers',
    fieldSchema: {
      type: [String],
      control: "checkboxgroup",
      optional: true,
      insertableIf: canSubscribe,
      autoform: {
        // omit: true
        noselect: true,
        type: "bootstrap-category",
        order: 50,
        options: function () {
          var subscribers = [{
            value: "123",
            label: "razdwatrzy"
          }];
          return subscribers;
        }
      },
      publish: true,
      join: {
        joinAs: "subscribersArray",
        collection: () => Users
      }
    }
  }
);

Posts.addField({
  fieldName: 'subscriberCount',
  fieldSchema: {
    type: Number,
    optional: true,
    autoform: {
      omit: true
    }
  }
});<commit_msg>simple refactoring<commit_after>import PublicationUtils from 'meteor/utilities:smart-publications'
import Posts from "meteor/nova:posts"
import Users from "meteor/nova:users"

// check if user can subscribe to post
const canSubscribe = user => Users.canDo(user, "posts.new");

Users.addField({
  fieldName: 'telescope.subscribedItems',
  fieldSchema: {
    type: Object,
    optional: true,
    blackbox: true,
    autoform: {
      omit: true
    }
  }
});

PublicationUtils.addToFields(
  Users.publishedFields.list, ["telescope.subscribedItems"]
)

Posts.addField(
  {
    fieldName: 'subscribers',
    fieldSchema: {
      type: [String],
      control: "checkboxgroup",
      optional: true,
      insertableIf: canSubscribe,
      autoform: {
        omit: true
      },
      publish: true,
      join: {
        joinAs: "subscribersArray",
        collection: () => Users
      }
    }
  }
);

Posts.addField({
  fieldName: 'subscriberCount',
  fieldSchema: {
    type: Number,
    optional: true,
    autoform: {
      omit: true
    }
  }
});
{'fraction_non_alphanumeric': 0.12229299363057325, 'fraction_numerical': 0.0021231422505307855, 'mean_word_length': 2.5164179104477613, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '7387535', 'n_tokens_mistral': 779, 'n_tokens_neox': 745, 'n_words': 163}