<commit_before>TopicController = RouteController.extend({
  subscriptions: function () {
    var topicId = this.params._id;
    var sortBy = this.params.query.sort_by;
    // var runAt = this.state.get('runAt');
    this._runAt = this._runAt || new Date();
    // if (!runAt) {
    //   this.state.set('runAt', new Date());
    // }
    return [
      Meteor.subscribe('singleTopic', topicId, this._runAt),
      Meteor.subscribe('topicComments', topicId, sortBy, 'pro', Session.get('itemsLimit')),
      Meteor.subscribe('topicComments', topicId, sortBy, 'con', Session.get('itemsLimit')),
      Meteor.subscribe('commentReplies', SessionAmplify.get('showingReplies'), sortBy)
    ];
  },
  onRun: function () {
    // Session.set('currentTab', 'topicComments');
    // this._runAt = new Date();
    // this.state.set('runAt', new Date());
    this._runAt = new Date();
    Session.set('itemsLimit', 1);
    SessionAmplify.set('showingReplies', []);  
    this.next();
  },
  action: function () {
    this.render();
    this.render('nav', { to: 'nav' });
    this.render('topicButtons', { to: 'pageButtons' });
    this.render('topicHeader', { to: 'pageHeader' });
    this.render('topicNav', { to: 'pageNav' });
  },
  data: function () {
    Session.set('currentTopic', this.params._id);
    return Topics.findOne({ '_id': this.params._id, 'isDeleted': false });
  }
});

Router.route('/topics/:_id', {
  name: 'topic',
  controller: TopicController,
  // fastRender: true
});<commit_msg>Fix scrolling to hash only once<commit_after>TopicController = RouteController.extend({
  subscriptions: function () {
    var topicId = this.params._id;
    var sortBy = this.params.query.sort_by;
    this._runAt = this._runAt || new Date();
    return [
      Meteor.subscribe('singleTopic', topicId, this._runAt),
      Meteor.subscribe('topicComments', topicId, sortBy, 'pro', Session.get('itemsLimit')),
      Meteor.subscribe('topicComments', topicId, sortBy, 'con', Session.get('itemsLimit')),
      Meteor.subscribe('commentReplies', SessionAmplify.get('showingReplies'), sortBy)
    ];
  },
  onRun: function () {
    this._scrollOnce = true;
    this._runAt = new Date();
    Session.set('itemsLimit', 1);
    SessionAmplify.set('showingReplies', []);  
    this.next();
  },
  action: function () {
    this.render();
    this.render('nav', { to: 'nav' });
    this.render('topicButtons', { to: 'pageButtons' });
    this.render('topicHeader', { to: 'pageHeader' });
    this.render('topicNav', { to: 'pageNav' });
  },
  data: function () {
    Session.set('currentTopic', this.params._id);
    return Topics.findOne({ '_id': this.params._id, 'isDeleted': false });
  },
  onAfterAction: function () {
    if (this.ready()) {
      var hash = this.params.hash;

      if (hash && this._scrollOnce) {
        this._scrollOnce = false;
        scrollToId(hash);
      }  
    }
  }
});

Router.route('/topics/:_id', {
  name: 'topic',
  controller: TopicController,
  // fastRender: true
});
{'fraction_non_alphanumeric': 0.18509856331440028, 'fraction_numerical': 0.0006682258603407952, 'mean_word_length': 3.415929203539823, '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': '4184080', 'n_tokens_mistral': 985, 'n_tokens_neox': 975, 'n_words': 180}