<commit_before>Meteor.publish("singlePost", function (idOrTitle) {
	// Get the current user
	var user = Meteor.users.findOne({_id: this.userId}) || {};
	// Get the permissions selector
	var permissionsSelector = PermissionsEnum.Posts.getPermissionsSelector(user);
	// Construct the selector
	var selector = {
		$and: [
			{
				$or: [
					{
						_id: idOrTitle
					},
					{
						title: idOrTitle
					}
				]
			},
			permissionsSelector
		]
	};
	// Return the cursor finding that post
	return Posts.find(selector);
});



Meteor.publish("postsByAuthor", function (authorId) {
	// Get the current user
	var user = Meteor.users.findOne({_id: this.userId}) || {};
	// Get the permissions selector
	var permissionsSelector = PermissionsEnum.Posts.getPermissionsSelector(user);
	// Construct the selector
	var selector = {
		$and: [
			{
				// Select only published posts
				published: true,
				// Authored by userId
				authors: {
					$elemMatch: {
						userId: authorId
					}
				}
			},
			permissionsSelector
		]
	};
	// Return the cursor finding those posts
	return Posts.find(selector);
});



Meteor.publish("latestPosts", function (limit) {
	// Get the current user
	var user = Meteor.users.findOne({_id: this.userId}) || {};
	// Get the permissions selector
	var permissionsSelector = PermissionsEnum.Posts.getPermissionsSelector(user);
	// Construct the selector
	var selector = {
		$and: [
			{
				// Select only published posts
				published: true
			},
			permissionsSelector
		]
	};
	// Sanitize the limit
	limit = parseInt(limit, 10);
	limit = isNaN(limit) ? 10 : limit;
	var options = {
		limit: limit,
		sort: {
			publishedOn: -1
		},
		fields: {
			title: 1,
			subtitle: 1,
			authors: 1,
			publishedOn: 1,
			published: 1,
			likedBy: 1
		}
	};
	// Return the cursor finding those posts
	return Posts.find(selector, options);
});



Meteor.publish("postDrafts", function (limit) {
	// Get the current user
	var user = Meteor.users.findOne({_id: this.userId}) || {};
	// Get the permissions selector
	var permissionsSelector = PermissionsEnum.Posts.getPermissionsSelector(user);
	// Construct the selector
	var selector = {
		$and: [
			{
				// Select only published posts<commit_msg>included post body into latestPosts<commit_after>Meteor.publish("singlePost", function (idOrTitle) {
	// Get the current user
	var user = Meteor.users.findOne({_id: this.userId}) || {};
	// Get the permissions selector
	var permissionsSelector = PermissionsEnum.Posts.getPermissionsSelector(user);
	// Construct the selector
	var selector = {
		$and: [
			{
				$or: [
					{
						_id: idOrTitle
					},
					{
						title: idOrTitle
					}
				]
			},
			permissionsSelector
		]
	};
	// Return the cursor finding that post
	return Posts.find(selector);
});



Meteor.publish("postsByAuthor", function (authorId) {
	// Get the current user
	var user = Meteor.users.findOne({_id: this.userId}) || {};
	// Get the permissions selector
	var permissionsSelector = PermissionsEnum.Posts.getPermissionsSelector(user);
	// Construct the selector
	var selector = {
		$and: [
			{
				// Select only published posts
				published: true,
				// Authored by userId
				authors: {
					$elemMatch: {
						userId: authorId
					}
				}
			},
			permissionsSelector
		]
	};
	// Return the cursor finding those posts
	return Posts.find(selector);
});



Meteor.publish("latestPosts", function (limit, retrieveAllFields) {
	// Get the current user
	var user = Meteor.users.findOne({_id: this.userId}) || {};
	// Get the permissions selector
	var permissionsSelector = PermissionsEnum.Posts.getPermissionsSelector(user);
	// Construct the selector
	var selector = {
		$and: [
			{
				// Select only published posts
				published: true
			},
			permissionsSelector
		]
	};
	// Sanitize the limit
	limit = parseInt(limit, 10);
	limit = isNaN(limit) ? 10 : limit;
	var options = {
		limit: limit,
		sort: {
			publishedOn: -1
		},
		fields: retrieveAllFields ? undefined : {
			title: 1,
			subtitle: 1,
			authors: 1,
			publishedOn: 1,
			published: 1,
			likedBy: 1
		}
	};
	// Return the cursor finding those posts
	return Posts.find(selector, options);
});



Meteor.publish("postDrafts", function (limit) {
	// Get the current user
	var user = Meteor.users.findOne({_id: this.userId}) || {};
	// Get the permissions selector
	var permissionsSelector = PermissionsEnum.Posts.getPermissionsSelector(user);
	// Construct the selector
	var selector = {
		$and: [
			{
				// Select only published posts
{'fraction_non_alphanumeric': 0.12286158631415241, 'fraction_numerical': 0.004887802710508776, 'mean_word_length': 3.0705244122965643, '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': '506050', 'n_tokens_mistral': 1682, 'n_tokens_neox': 1403, 'n_words': 370}