<commit_before>/*****************************************************************************/
/* Forum: Event Handlers */
/*****************************************************************************/
Template.Forum.events({
  'click #btn-ask': function(event, template) {
    var forumId = Router.current().params.id;
    Router.go('ask', {
      forumId: forumId
    });
  }
});

/*****************************************************************************/
/* Forum: Helpers */
/*****************************************************************************/
Template.Forum.helpers({
  questions: function() {
    var queries = Session.get('forumQuery').split(',');
    var tags = [];
    var topics = [];
    for (var i = 0; i < queries.length; i++) {
      var q = queries[i];
      if (q.charAt(0) === '#') {
        tags.push(q);
      } else if (q !== '') {
        topics.push(q);
      }
    }

    var forumId = Router.current().params.id;

    function formatQuery(forumId, tags, topics) {
      var query = {};
      query.forumId = forumId;
      if (tags.length > 0) {
        query.tags = {
          '$in': tags
        };
      }
      if (topics.length > 0) {
        query.title = {
          '$in': topics
        };
      }
      return query;
    }

    return Questions.find(formatQuery(forumId, tags, topics), {
      sort: {<commit_msg>changed to OR search instead for forum<commit_after>/*****************************************************************************/
/* Forum: Event Handlers */
/*****************************************************************************/
Template.Forum.events({
  'click #btn-ask': function(event, template) {
    var forumId = Router.current().params.id;
    Router.go('ask', {
      forumId: forumId
    });
  }
});

/*****************************************************************************/
/* Forum: Helpers */
/*****************************************************************************/
Template.Forum.helpers({
  questions: function() {
    var queries = Session.get('forumQuery').split(',');
    var tags = [];
    var topics = [];
    for (var i = 0; i < queries.length; i++) {
      var q = queries[i];
      if (q.charAt(0) === '#') {
        tags.push(q);
      } else if (q !== '') {
        topics.push(q);
      }
    }

    var forumId = Router.current().params.id;

    function formatQuery(forumId, tags, topics) {
      var query = [];
      if (tags.length > 0) {
        query.push({
          tags:{
            '$in': tags
          },
          forumId: forumId
        });
      }
      if (topics.length > 0) {
        query.push({
          title:{
            '$in': topics
          },
          forumId: forumId
        });
      }

      if (query.length == 0) {
        return {
          forumId: forumId
        };
      } else {
        return {
          $or: query
        };
      }
    }

    return Questions.find(formatQuery(forumId, tags, topics), {
      sort: {
{'fraction_non_alphanumeric': 0.34306814367237326, 'fraction_numerical': 0.0030211480362537764, 'mean_word_length': 2.3940774487471526, 'pattern_counts': {'":': 0, '<': 5, '<?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': '4731914', 'n_tokens_mistral': 829, 'n_tokens_neox': 777, 'n_words': 166}