<commit_before>:ruby
  event_type = EarlyDispositionRequestUpdateEvent.asset_event_type
  can_view_early_disposition = (event_type.active and can?(:manage, EarlyDispositionRequestUpdateEvent))
  early_events = Asset.where(organization_id: @organization_list).joins(:early_disposition_requests).where(asset_events: {state: 'new'}).count
  transferred_assets = Asset.where(organization_id: @organization_list).where('asset_tag = object_key').count

  assets = Asset.operational.where(:organization_id => @organization_list).group(:asset_subtype_id).count

  grouped_assets = Hash.new
  AssetType.all.each do |type|
    subtype_counts = assets.select{|k, v| type.asset_subtypes.ids.include? k}
    if subtype_counts.length > 0
      grouped_assets[type.id] = [type, subtype_counts]
    end
  end



  column_count = (grouped_assets.count < 4 ? grouped_assets.count + 1 : 6)

  types_per_column = (grouped_assets.count/(column_count-1).to_f).ceil

  extras = grouped_assets.count%(column_count-1)


%li{:class => "dropdown #{get_nav_link_class('assets')}"}
  = link_to "#", :class => "dropdown-toggle", :data => {"toggle" => "dropdown"}, :title => 'Inventory' do
    %i.fa.fa-bus.fa-2x
    %b.caret
  %ul.dropdown-menu{class: "columns-#{column_count}"}
    .row
      %div{class: "col-sm-#{12/column_count}"}
        %ul.multi-column-dropdown
          %li.text-left
            = link_to manufacturers_path do
              %i.fa.fa-fw.fa-star
              Manufacturers
          %li.divider
          %li.text-left
            = link_to asset_groups_path do
              %i.fa.fa-tags.fa-fw
              Groups
          - if (early_events > 0 && can_view_early_disposition) || (transferred_assets > 0 && can?(:accept_transfers, Asset))
            %li.divider
            - if early_events > 0 && can_view_early_disposition
              %li.text-left{:style => 'width:255px'}
                = link_to inventory_index_path(:early_disposition => 1) do
                  %i.fa.fa-fw{:class => event_type.display_icon_name}
                  = "Early Disposition Proposed (#{early_events})"
            - if transferred_assets > 0 && can?(:accept_transfers, Asset)
              %li.text-left{:style => 'width:255px'}
                = link_to inventory_index_path(:transferred_assets => 1) do
                  %i.fa.fa-refresh.fa-fw
                  = "Newly Transferred Assets (#{transferred_assets})"
          %li.divider
          %li.text-left
            = link_to reset_searches_path(:search_type => SearchesController::ASSET_SEARCH_TYPE) do
              %i.fa.fa-search.fa-fw
              Query
          - SystemConfig.transam_module_names.each do |mod|
            = render :partial => "shared/#{mod}_inventory_nav_first_column" rescue nil
          - if !Policy.where('parent_id IS NOT NULL AND organization_id IN (?)', @organization_list).pluck(:organization_id).empty? && (can? :create, Asset)
            %li.divider
            %li.text-left
              = link_to new_asset_inventory_index_path do
                %i.fa.fa-plus.fa-fw
                Add Asset
            %li.divider
            %li.text-left
              = link_to uploads_path, :style => 'font-weight:bold;' do
                %i.fa.fa-file-excel-o.fa-fw
                Bulk Updates
            %li.text-left.small
              = link_to templates_uploads_path do
                %i.fa.fa-download.fa-fw
                Download Template
            %li.text-left.small
              = link_to new_upload_path do
                %i.fa.fa-upload.fa-fw
                Upload Template
      - idx = -1
      - (column_count-1).times do
        - idx += 1
        - if idx < grouped_assets.count
          - type = grouped_assets[grouped_assets.keys[idx]][0]
          - subtypes = grouped_assets[grouped_assets.keys[idx]][1]

          %div{class: "col-sm-#{12/column_count}"}
            %ul.multi-column-dropdown
              %li.text-left
                = link_to inventory_index_path(:asset_type => type, :asset_subtype => 0, :asset_group => 0), :style => 'font-weight:bold;'  do
                  %i{:class => "#{type.display_icon_name} fa-fw"}
                  = type.name.pluralize(2)
              - subtypes.keys.each do |as|
                %li.text-left.small
                  - asset_subtype = AssetSubtype.find(as)
                  = link_to asset_subtype.name, inventory_index_path(:asset_subtype => asset_subtype, :asset_group => 0)



              - repeat = extras > 0 ? (types_per_column-1) : (types_per_column-2)
              - extras -= 1
              - (repeat).times do
                - idx += 1
                - if idx < grouped_assets.count
                  - type = grouped_assets[grouped_assets.keys[idx]][0]
                  - subtypes = grouped_assets[grouped_assets.keys[idx]][1]

                  %li.divider
                  %li.text-left.small
                    = link_to inventory_index_path(:asset_type => type, :asset_subtype => 0, :asset_group => 0), :style => 'font-weight:bold;'  do
                      %i{:class => "#{type.display_icon_name} fa-fw"}
                      = type.name.pluralize(2)
                  - subtypes.keys.each do |as|
                    %li.text-left.small
                      - asset_subtype = AssetSubtype.find(as)
                      = link_to asset_subtype.name, inventory_index_path(:asset_subtype => asset_subtype, :asset_group => 0)

<commit_msg>fix divide by 0 in inventory nav if there are no assets<commit_after>:ruby
  event_type = EarlyDispositionRequestUpdateEvent.asset_event_type
  can_view_early_disposition = (event_type.active and can?(:manage, EarlyDispositionRequestUpdateEvent))
  early_events = Asset.where(organization_id: @organization_list).joins(:early_disposition_requests).where(asset_events: {state: 'new'}).count
  transferred_assets = Asset.where(organization_id: @organization_list).where('asset_tag = object_key').count

  assets = Asset.operational.where(:organization_id => @organization_list).group(:asset_subtype_id).count

  grouped_assets = Hash.new
  AssetType.all.each do |type|
    subtype_counts = assets.select{|k, v| type.asset_subtypes.ids.include? k}
    if subtype_counts.length > 0
      grouped_assets[type.id] = [type, subtype_counts]
    end
  end



  column_count = (grouped_assets.count < 4 ? grouped_assets.count + 1 : 6)

  unless grouped_assets.count == 0
    types_per_column = (grouped_assets.count/(column_count-1).to_f).ceil
    extras = grouped_assets.count%(column_count-1)
  end

%li{:class => "dropdown #{get_nav_link_class('assets')}"}
  = link_to "#", :class => "dropdown-toggle", :data => {"toggle" => "dropdown"}, :title => 'Inventory' do
    %i.fa.fa-bus.fa-2x
    %b.caret
  %ul.dropdown-menu{class: "columns-#{column_count}"}
    .row
      %div{class: "col-sm-#{12/column_count}"}
        %ul.multi-column-dropdown
          %li.text-left
            = link_to manufacturers_path do
              %i.fa.fa-fw.fa-star
              Manufacturers
          %li.divider
          %li.text-left
            = link_to asset_groups_path do
              %i.fa.fa-tags.fa-fw
              Groups
          - if (early_events > 0 && can_view_early_disposition) || (transferred_assets > 0 && can?(:accept_transfers, Asset))
            %li.divider
            - if early_events > 0 && can_view_early_disposition
              %li.text-left{:style => 'width:255px'}
                = link_to inventory_index_path(:early_disposition => 1) do
                  %i.fa.fa-fw{:class => event_type.display_icon_name}
                  = "Early Disposition Proposed (#{early_events})"
            - if transferred_assets > 0 && can?(:accept_transfers, Asset)
              %li.text-left{:style => 'width:255px'}
                = link_to inventory_index_path(:transferred_assets => 1) do
                  %i.fa.fa-refresh.fa-fw
                  = "Newly Transferred Assets (#{transferred_assets})"
          %li.divider
          %li.text-left
            = link_to reset_searches_path(:search_type => SearchesController::ASSET_SEARCH_TYPE) do
              %i.fa.fa-search.fa-fw
              Query
          - SystemConfig.transam_module_names.each do |mod|
            = render :partial => "shared/#{mod}_inventory_nav_first_column" rescue nil
          - if !Policy.where('parent_id IS NOT NULL AND organization_id IN (?)', @organization_list).pluck(:organization_id).empty? && (can? :create, Asset)
            %li.divider
            %li.text-left
              = link_to new_asset_inventory_index_path do
                %i.fa.fa-plus.fa-fw
                Add Asset
            %li.divider
            %li.text-left
              = link_to uploads_path, :style => 'font-weight:bold;' do
                %i.fa.fa-file-excel-o.fa-fw
                Bulk Updates
            %li.text-left.small
              = link_to templates_uploads_path do
                %i.fa.fa-download.fa-fw
                Download Template
            %li.text-left.small
              = link_to new_upload_path do
                %i.fa.fa-upload.fa-fw
                Upload Template
      - idx = -1
      - (column_count-1).times do
        - idx += 1
        - if idx < grouped_assets.count
          - type = grouped_assets[grouped_assets.keys[idx]][0]
          - subtypes = grouped_assets[grouped_assets.keys[idx]][1]

          %div{class: "col-sm-#{12/column_count}"}
            %ul.multi-column-dropdown
              %li.text-left
                = link_to inventory_index_path(:asset_type => type, :asset_subtype => 0, :asset_group => 0), :style => 'font-weight:bold;'  do
                  %i{:class => "#{type.display_icon_name} fa-fw"}
                  = type.name.pluralize(2)
              - subtypes.keys.each do |as|
                %li.text-left.small
                  - asset_subtype = AssetSubtype.find(as)
                  = link_to asset_subtype.name, inventory_index_path(:asset_subtype => asset_subtype, :asset_group => 0)



              - repeat = extras > 0 ? (types_per_column-1) : (types_per_column-2)
              - extras -= 1
              - (repeat).times do
                - idx += 1
                - if idx < grouped_assets.count
                  - type = grouped_assets[grouped_assets.keys[idx]][0]
                  - subtypes = grouped_assets[grouped_assets.keys[idx]][1]

                  %li.divider
                  %li.text-left.small
                    = link_to inventory_index_path(:asset_type => type, :asset_subtype => 0, :asset_group => 0), :style => 'font-weight:bold;'  do
                      %i{:class => "#{type.display_icon_name} fa-fw"}
                      = type.name.pluralize(2)
                  - subtypes.keys.each do |as|
                    %li.text-left.small
                      - asset_subtype = AssetSubtype.find(as)
                      = link_to asset_subtype.name, inventory_index_path(:asset_subtype => asset_subtype, :asset_group => 0)


{'fraction_non_alphanumeric': 0.12151921847895554, 'fraction_numerical': 0.0080343284944764, 'mean_word_length': 2.0242959690778575, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 71, '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': '6601026', 'n_tokens_mistral': 3576, 'n_tokens_neox': 3339, 'n_words': 557}