<commit_before><div class="page-header">
  <h1><%=t '.title', :default => "Search Results" %></h1>
</div>

<div class="row">
  <div class="span12" style="text-align:right">
    <span data-toggle="collapse" data-target="#advanced-search">Show advanced search</span>
  </div>
</div>


<div class="row">
  <%= form_tag search_index_path, method: :get, id: "search-form"%>
  <%= hidden_field_tag :adv, '1' %>

  <div class="collapse <%= "in" if params[:adv] %>" id="advanced-search">
    <div class="span4">
      <fieldset>
        <label for="first_name">First name</label>
        <%= text_field_tag :first_name, params[:first_name], class: "input" %>

        <label for="last_name">Last name</label>
        <%= text_field_tag :last_name, params[:last_name], class: "input" %>

        <label for="email_address">Email address</label>
        <%= text_field_tag :email_address, params[:email_address], class: "input" %>

        <label for="postal_code">ZIP Code</label>
        <%= text_field_tag :postal_code, params[:postal_code], class: "input" %>

        <label for="postal_code">Neighborhood</label>
        <%= text_field_tag :neighborhood, params[:neighborhood], class: "input" %>

        <label for="address">Phone Number</label>
        <%= text_field_tag :phone_number, params[:phone_number], class: 'input-large', placeholder: "11 digit number start with 1" %>
      </fieldset>
    </div>

    <div class="span3">

      <label for="device_id_type">Device Type</label>
      <%= select_tag :device_id_type,
        options_for_select([[human_device_type_name(0), 0],[human_device_type_name(1), 1], [human_device_type_name(2), 2], [human_device_type_name(3), 3]] , include_blank: true, selected: params[:device_id_type]) , :multiple => true,  :class => "multiple", :size => '4'%>
      <label for="connection_id_type">Connection Type</label>
      <%= select_tag :connection_id_type,
        options_for_select([[human_connection_type_name(0), 0],[human_connection_type_name(1), 1], [human_connection_type_name(4), 4], [human_connection_type_name(3), 3], [human_connection_type_name(2), 2]] , include_blank: true, selected: params[:connection_id_type]) , :multiple => true,  :class => "multiple", :size => '5' %>

      <label for="preferred contact method">Preferred Contact Method</label>
      <%= select_tag :preferred_contact_method,
        options_for_select([["All", '*'],["Email", 'EMAIL'], ["SMS", 'SMS']], include_blank: true, selected: params[:preferred_contact_method]) , :class => "input" %>

    </div>

    <div class="span5">

      <label for="device_description">Device description</label>
      <%= text_field_tag :device_description, params[:device_description], :class => "input span5" %>

      <label for="connection_description">Connection description</label>
      <%= text_field_tag :connection_description, params[:connection_description], :class => "input span5" %>

      <label for="tags">Tags</label>
        <%= text_field_tag :tags,
                            params[:tags],
                            class: 'tokenfield input-large span5',
                            data: { search_url: '/taggings/search?q=%QUERY',
                                    submit_id: 'search-tag-hidden-input',
                                    pre_populate: @tags
                                  }
                          %>
        <%= hidden_field_tag :tags_hidden,'', id:'search-tag-hidden-input' %>
      <label for='additional'>&nbsp;</label>
      <span data-toggle="collapse" data-target="#additional-options"  class="btn btn-default">Click to Show Additional Options</span>
      <div class="collapse" id="additional-options">
        <label for="verified">Verified?</label>
        <%= select_tag :verified,
             options_for_select([[nil,nil]] + Person.uniq.pluck(:verified), selected: params[:verified]), :class => "input" %>

        <label for="geography_id">Ward</label>
        <%= text_field_tag :geography_id, params[:geography_id], :class => "input-small" %>

        <label for="address">Address</label>
        <%= text_field_tag :address, params[:address], :class => 'input-large' %>

        <label for="submissions">Form submission content</label>
        <%= text_field_tag :submissions, params[:submissions], :class => "input span4" %>

        <label for="event_id">Event</label>
        <%= select_tag :event_id,
              options_for_select([[nil, nil]] + Event.all.order(:name).collect{|event| [event.name, event.id]}, selected: params[:event_id]),
              :class => "input" %>
        </div>
    </div>
  </div>

  <div class="span12">
    <%= submit_tag "Search", :name => nil, :class => "btn btn-primary" %>
  </div>

  </form>
</div>

<% if @results.any? %>
<div class="row">
  <div class="span12">

    <p class="pull-right">
      Showing <%= @results.size %> <%= 'result'.pluralize(@results) %><% if @results.total > @results.size -%> of <%= @results.total %> total<% end -%>
    </p>
    <table class="table table-striped">
      <% @results.each_with_index do |result, idx| %>
      <% #result = result.person %>
      <tr>
        <td class="span4">
          <strong><%= link_to "#{result.first_name} #{result.last_name}", person_path(:id => result.id) %></strong>
          <%= render partial: 'people/add_remove_cart',locals: {person: Person.find_by(id: result.id)} %>
          <br/><br/>
           Tags: <% if !(result.tag_values.blank?) %><%= search_result_field result.tag_values, :tags %><% end %>
        </td>
        <td class="span4">
          Address: <%= search_result_field result.address_1, :address  %><br/>
          City: <%= search_result_field result.city, :city %>  ZIP: <%= search_result_field result.postal_code, :postal_code %><br/>
          Ward: <%= search_result_field result.geography_id, :geography_id %><br/>
          Phone: <%= search_result_field number_to_phone(result.phone_number), :phone_number %><br/>
          Email: <%= search_result_field result.email_address, :email_address %><br/>
          Verified?: <%= search_result_field result.verified, :verified %>

        </td>
        <td class="span4">
          Primary Device: <%= search_result_field result.primary_device_description, :device_description %> (<%= search_result_field human_device_type_name(result.primary_device_id), :device_id_type %>)<br>
          Secondary Device: <%= search_result_field result.secondary_device_description, :device_description %> (<%= search_result_field human_device_type_name(result.secondary_device_id), :device_id_type %>)<br>
          Primary Connection: <%= search_result_field human_connection_type_name(result.primary_connection_id), :connection_id %> <%= search_result_field result.primary_connection_description, :connection_description %><br><commit_msg>dealing with people who are deactivated<commit_after><div class="page-header">
  <h1><%=t '.title', :default => "Search Results" %></h1>
</div>

<div class="row">
  <div class="span12" style="text-align:right">
    <span data-toggle="collapse" data-target="#advanced-search">Show advanced search</span>
  </div>
</div>


<div class="row">
  <%= form_tag search_index_path, method: :get, id: "search-form"%>
  <%= hidden_field_tag :adv, '1' %>

  <div class="collapse <%= "in" if params[:adv] %>" id="advanced-search">
    <div class="span4">
      <fieldset>
        <label for="first_name">First name</label>
        <%= text_field_tag :first_name, params[:first_name], class: "input" %>

        <label for="last_name">Last name</label>
        <%= text_field_tag :last_name, params[:last_name], class: "input" %>

        <label for="email_address">Email address</label>
        <%= text_field_tag :email_address, params[:email_address], class: "input" %>

        <label for="postal_code">ZIP Code</label>
        <%= text_field_tag :postal_code, params[:postal_code], class: "input" %>

        <label for="postal_code">Neighborhood</label>
        <%= text_field_tag :neighborhood, params[:neighborhood], class: "input"%>

        <label for="address">Phone Number</label>
        <%= text_field_tag :phone_number, params[:phone_number], class: 'input-large', placeholder: "11 digit number start with 1" %>
      </fieldset>
    </div>

    <div class="span3">

      <label for="device_id_type">Device Type</label>
      <%= select_tag :device_id_type,
        options_for_select([[human_device_type_name(0), 0],[human_device_type_name(1), 1], [human_device_type_name(2), 2], [human_device_type_name(3), 3]] , include_blank: true, selected: params[:device_id_type]) , :multiple => true,  :class => "multiple", :size => '4'%>
      <label for="connection_id_type">Connection Type</label>
      <%= select_tag :connection_id_type,
        options_for_select([[human_connection_type_name(0), 0],[human_connection_type_name(1), 1], [human_connection_type_name(4), 4], [human_connection_type_name(3), 3], [human_connection_type_name(2), 2]] , include_blank: true, selected: params[:connection_id_type]) , :multiple => true,  :class => "multiple", :size => '5' %>

      <label for="preferred contact method">Preferred Contact Method</label>
      <%= select_tag :preferred_contact_method,
        options_for_select([["All", '*'],["Email", 'EMAIL'], ["SMS", 'SMS']], include_blank: true, selected: params[:preferred_contact_method]) , :class => "input" %>

    </div>

    <div class="span5">

      <label for="device_description">Device description</label>
      <%= text_field_tag :device_description, params[:device_description], :class => "input span5" %>

      <label for="connection_description">Connection description</label>
      <%= text_field_tag :connection_description, params[:connection_description], :class => "input span5" %>

      <label for="tags">Tags</label>
        <%= text_field_tag :tags,
                            params[:tags],
                            class: 'tokenfield input-large span5',
                            data: { search_url: '/taggings/search?q=%QUERY',
                                    submit_id: 'search-tag-hidden-input',
                                    pre_populate: @tags
                                  }
                          %>
        <%= hidden_field_tag :tags_hidden,'', id:'search-tag-hidden-input' %>
      <label for='additional'>&nbsp;</label>
      <span data-toggle="collapse" data-target="#additional-options"  class="btn btn-default">Click to Show Additional Options</span>
      <div class="collapse" id="additional-options">
        <label for="verified">Verified?</label>
        <%= select_tag :verified,
             options_for_select([[nil,nil]] + Person.uniq.pluck(:verified), selected: params[:verified]), :class => "input" %>

        <label for="geography_id">Ward</label>
        <%= text_field_tag :geography_id, params[:geography_id], :class => "input-small" %>

        <label for="address">Address</label>
        <%= text_field_tag :address, params[:address], :class => 'input-large' %>

        <label for="submissions">Form submission content</label>
        <%= text_field_tag :submissions, params[:submissions], :class => "input span4" %>

        <label for="event_id">Event</label>
        <%= select_tag :event_id,
              options_for_select([[nil, nil]] + Event.all.order(:name).collect{|event| [event.name, event.id]}, selected: params[:event_id]),
              :class => "input" %>
        </div>
    </div>
  </div>

  <div class="span12">
    <%= submit_tag "Search", :name => nil, :class => "btn btn-primary" %>
  </div>

  </form>
</div>

<% if @results.any? %>
<div class="row">
  <div class="span12">

    <p class="pull-right">
      Showing <%= @results.size %> <%= 'result'.pluralize(@results) %><% if @results.total > @results.size -%> of <%= @results.total %> total<% end -%>
    </p>
    <table class="table table-striped">
      <% @results.each_with_index do |result, idx| %>
      <% next unless Person.find_by(id: result.id) %>
      <tr>
        <td class="span4">
          <strong><%= link_to "#{result.first_name} #{result.last_name}", person_path(:id => result.id) %></strong>
          <%= render partial: 'people/add_remove_cart',locals: {person: Person.find_by(id: result.id)} %>
          <br/><br/>
           Tags: <% if !(result.tag_values.blank?) %><%= search_result_field result.tag_values, :tags %><% end %>
        </td>
        <td class="span4">
          Address: <%= search_result_field result.address_1, :address  %><br/>
          City: <%= search_result_field result.city, :city %>  ZIP: <%= search_result_field result.postal_code, :postal_code %><br/>
          Ward: <%= search_result_field result.geography_id, :geography_id %><br/>
          Neighborhood: <%= search_result_field result.neighborhood, :neighborhood %><br/>
          Phone: <%= search_result_field number_to_phone(result.phone_number), :phone_number %><br/>
          Email: <%= search_result_field result.email_address, :email_address %><br/>
          Verified?: <%= search_result_field result.verified, :verified %>

        </td>
        <td class="span4">
          Primary Device: <%= search_result_field result.primary_device_description, :device_description %> (<%= search_result_field human_device_type_name(result.primary_device_id), :device_id_type %>)<br>
          Secondary Device: <%= search_result_field result.secondary_device_description, :device_description %> (<%= search_result_field human_device_type_name(result.secondary_device_id), :device_id_type %>)<br>
          Primary Connection: <%= search_result_field human_connection_type_name(result.primary_connection_id), :connection_id %> <%= search_result_field result.primary_connection_description, :connection_description %><br>
{'fraction_non_alphanumeric': 0.168997668997669, 'fraction_numerical': 0.006264568764568765, 'mean_word_length': 3.5809142475809144, 'pattern_counts': {'":': 0, '<': 279, '<?xml version=': 0, '>': 317, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5280199', 'n_tokens_mistral': 4489, 'n_tokens_neox': 4186, 'n_words': 807}