<commit_before>class MessagesController < ApplicationController
  # GET /messages
  # GET /messages.xml
  def index
    @users = current_user
    @messages = @users.messages
    

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @messages }
    end
  end
  def new
    @user = User.find_by_login(params[:user_id])
    @replyto = @user.email
    @to = @user.email
    @bseniorleads=(@user.battalion.soldiers.find(:all, :conditions => ["seniorleader = ?", "Yes"]))
    @position = @user.position
    @battalion = @user.battalion
    @soldier = Soldier.all
    @attached = Company.find(:all, :conditions => ["attached_id = ?", @battalion])
    @attach_soldiers = Soldier.find(:all, :conditions => ["company_id = ?", @attached])
    if ["Battalion Commander","Command Sergeant Major","FRSA","Battalion FRG Leader","Battalion FRG Co-Leader","Rear-D Commander"].include?(@position)
      @bnok = (@user.battalion.primaries).collect(&:email).select{|s| !s.blank?}.join(", ")
      @bspouses = (@user.battalion.primaries.find(:all,:conditions => ["relationship = 'Spouse' AND contacted = 'Yes'"])).collect(&:email).select{|s| !s.blank?}.join(", ")
      @bsoldiers= (@user.battalion.soldiers).collect(&:email).select{|s| !s.blank?}.join(", ")
      @bsoldierspouse=((@user.battalion.soldiers)+(@user.battalion.primaries.find(:all,:conditions => ["relationship = 'Spouse' AND contacted = 'Yes'"]))).collect(&:email).select{|s| !s.blank?}.join(", ")
      @ballcontacts=((@user.battalion.soldiers)+(@user.battalion.primaries)+(@user.battalion.additionals)+(@attach_soldiers)).collect(&:email).select{|s| !s.blank?}.join(", ")
      @senior_spouse = (@user.battalion.soldiers.find(:all, :select => 'primaries.*', :joins => [:primaries], :conditions => ["seniorleader = ? and primaries.relationship = ?", "Yes", "Spouse"])).collect(&:email).select{|s| !s.blank?}.join(", ")
      @bfrgleaders=(@user.battalion.users.find(:all, :conditions => ["position = 'FRG Leader'"])).collect(&:email).select{|s| !s.blank?}.join(", ")
      @attached_company=(@attach_soldiers).collect(&:email).select{|s| !s.blank?}.join(", ")
    else ["Company Commander","1st Sergeant","FRG Leader"].include?(@position)
      @nok = (@user.company.primaries).collect(&:email).select{|s| !s.blank?}.join(", ")
      @spouses = (@user.company.primaries.find(:all,:conditions => ["relationship = 'Spouse' AND contacted = 'Yes'"])).collect(&:email).select{|s| !s.blank?}.join(", ")
      @soldiers= (@user.company.soldiers).collect(&:email).select{|s| !s.blank?}.join(", ")
      @soldierspouse=((@user.company.soldiers)+(@user.company.primaries.find(:all,:conditions => ["relationship = 'Spouse' AND contacted = 'Yes'"]))).collect(&:email).select{|s| !s.blank?}.join(", ")
      @allcontacts=((@user.company.soldiers)+(@user.company.primaries)+(@user.company.additionals)).collect(&:email).select{|s| !s.blank?}.join(", ")
    end 
    
    @message = Message.new
   end
   
   def edit
    @message = Message.find(params[:id])
   end
    
  def create
    @user = current_user.login
    @message = Message.new(params[:message])<commit_msg>add battalion co-leader to messages<commit_after>class MessagesController < ApplicationController
  # GET /messages
  # GET /messages.xml
  def index
    @users = current_user
    @messages = @users.messages
    

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @messages }
    end
  end
  def new
    @user = User.find_by_login(params[:user_id])
    @replyto = @user.email
    @to = @user.email
    @bseniorleads=(@user.battalion.soldiers.find(:all, :conditions => ["seniorleader = ?", "Yes"]))
    @position = @user.position
    @battalion = @user.battalion
    @soldier = Soldier.all
    @attached = Company.find(:all, :conditions => ["attached_id = ?", @battalion])
    @attach_soldiers = Soldier.find(:all, :conditions => ["company_id = ?", @attached])
    if ["Battalion Commander","Command Sergeant Major","FRSA","Battalion FRG Leader","Battalion FRG Co-Leader","Rear-D Commander"].include?(@position)
      @bnok = (@user.battalion.primaries).collect(&:email).select{|s| !s.blank?}.join(", ")
      @bspouses = (@user.battalion.primaries.find(:all,:conditions => ["relationship = 'Spouse' AND contacted = 'Yes'"])).collect(&:email).select{|s| !s.blank?}.join(", ")
      @bsoldiers= (@user.battalion.soldiers).collect(&:email).select{|s| !s.blank?}.join(", ")
      @bsoldierspouse=((@user.battalion.soldiers)+(@user.battalion.primaries.find(:all,:conditions => ["relationship = 'Spouse' AND contacted = 'Yes'"]))).collect(&:email).select{|s| !s.blank?}.join(", ")
      @ballcontacts=((@user.battalion.soldiers)+(@user.battalion.primaries)+(@user.battalion.additionals)+(@attach_soldiers)).collect(&:email).select{|s| !s.blank?}.join(", ")
      @senior_spouse = (@user.battalion.soldiers.find(:all, :select => 'primaries.*', :joins => [:primaries], :conditions => ["seniorleader = ? and primaries.relationship = ?", "Yes", "Spouse"])).collect(&:email).select{|s| !s.blank?}.join(", ")
      @bfrgleaders=(@user.b<EMAIL>.users.find(:all, :conditions => ["position = ? AND position = ?",'FRG Leader','Battalion FRG Co-Leader'])).collect(&:email).select{|s| !s.blank?}.join(", ")
      @attached_company=(@attach_soldiers).collect(&:email).select{|s| !s.blank?}.join(", ")
    else ["Company Commander","1st Sergeant","FRG Leader"].include?(@position)
      @nok = (@user.company.primaries).collect(&:email).select{|s| !s.blank?}.join(", ")
      @spouses = (@user.company.primaries.find(:all,:conditions => ["relationship = 'Spouse' AND contacted = 'Yes'"])).collect(&:email).select{|s| !s.blank?}.join(", ")
      @soldiers= (@user.company.soldiers).collect(&:email).select{|s| !s.blank?}.join(", ")
      @soldierspouse=((@user.company.soldiers)+(@user.company.primaries.find(:all,:conditions => ["relationship = 'Spouse' AND contacted = 'Yes'"]))).collect(&:email).select{|s| !s.blank?}.join(", ")
      @allcontacts=((@user.company.soldiers)+(@user.company.primaries)+(@user.company.additionals)).collect(&:email).select{|s| !s.blank?}.join(", ")
    end 
    
    @message = Message.new
   end
   
   def edit
    @message = Message.find(params[:id])
   end
    
  def create
    @user = current_user.login
    @message = Message.new(params[:message])
{'fraction_non_alphanumeric': 0.21776729559748428, 'fraction_numerical': 0.00031446540880503143, 'mean_word_length': 4.684539767649687, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 28, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, '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': '3503946', 'n_tokens_mistral': 2205, 'n_tokens_neox': 2145, 'n_words': 305}