<commit_before>class PagesController < ApplicationController
  before_filter :sync_posts, :only => [:home, :check_new]
  before_filter :get_newsgroups, :only => :home

  def home
    @current_user.real_name = ENV['WEBAUTH_LDAP_CN']
    @current_user.save!
  end
  
  def new_user
  end
  
  def check_new
  end
  
  private
  
    def sync_posts
      if not File.exists?('tmp/syncing.txt') and
          (not File.exists?('tmp/lastsync.txt') or File.mtime('tmp/lastsync.txt') < 1.minute.ago)
        FileUtils.touch('tmp/syncing.txt')
        Newsgroup.sync_all!
        FileUtils.rm('tmp/syncing.txt')
        FileUtils.touch('tmp/lastsync.txt')
      end
    end
    
    def get_newsgroups
      @newsgroups = if @current_user.preferences[:show_cancel] == '1'
        Newsgroup.all
      else
        Newsgroup.where(:status => 'y')
      end
    end
end<commit_msg>Don't sync with xhr home requests<commit_after>class PagesController < ApplicationController
  before_filter :sync_posts, :only => [:home, :check_new]
  before_filter :get_newsgroups, :only => :home

  def home
    @current_user.real_name = ENV['WEBAUTH_LDAP_CN']
    @current_user.save!
  end
  
  def new_user
  end
  
  def check_new
  end
  
  private
  
    def sync_posts
      if not (action_name == 'home' and request.xhr?)
        if not File.exists?('tmp/syncing.txt') and
            (not File.exists?('tmp/lastsync.txt') or File.mtime('tmp/lastsync.txt') < 1.minute.ago)
          FileUtils.touch('tmp/syncing.txt')
          Newsgroup.sync_all!
          FileUtils.touch('tmp/lastsync.txt')
          FileUtils.rm('tmp/syncing.txt')
        end
      end
    end
    
    def get_newsgroups
      @newsgroups = if @current_user.preferences[:show_cancel] == '1'
        Newsgroup.all
      else
        Newsgroup.where(:status => 'y')
      end
    end
end
{'fraction_non_alphanumeric': 0.1147986942328618, 'fraction_numerical': 0.002176278563656148, 'mean_word_length': 2.584795321637427, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, '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': '4313941', 'n_tokens_mistral': 638, 'n_tokens_neox': 622, 'n_words': 121}