<commit_before># Convenience methods consumed in the dashboards controller index view
module DashboardsHelper
  def week_range(date: DateTime.now.in_time_zone, start_day: :monday)
    week_start = date.beginning_of_week start_day
    week_end = date.end_of_week start_day
    week_start_string = week_start.strftime('%B %-d')
    week_end_string = if week_start.month == week_end.month
                        week_end.strftime('%-d')
                      else
                        week_end.strftime('%B %-d')
                      end
    "#{week_start_string} - #{week_end_string}"
  end

  def voicemail_options
    enum_text = { not_specified: 'No instructions; no ID VM',
                  no: 'Do not leave a voicemail',
                  yes: 'Voicemail OK, ID OK' }
    vm_options = Patient::VOICEMAIL_PREFERENCE

    vm_options.map { |option| [enum_text[option], option] }
  end

  def remove_from_call_list_glyphicon
    safe_join [
      tag(:span, class: ['glyphicon', 'glyphicon-remove'], aria: { hidden: true }),
      tag(:span, class: ['sr-only'], text: 'Remove call')
    ]
  end

  def call_glyphicon
    safe_join [
      tag(:span, class: ['glyphicon', 'glyphicon-earphone'], aria: { hidden: true }),
      tag(:span, class: ['sr-only'], text: 'Call')
    ]
  end

  def th_autosortable(column_name, type, local_assigns)
    # Throw a flag unless sorting by string, int, or float
    raise 'Bad datatype' unless %w(string string-ins int float).include? type
    content_tag :th, data: { sort: type } do
      safe_join([column_name, autosort_arrow_span(local_assigns)], ' ').strip
    end
  end

  # span that holds the up/down arrow
  def autosort_arrow_span(local_assigns)
    return '' unless local_assigns[:autosortable]
    content_tag(:span, '[-]', class: 'arrow')
  end
end<commit_msg>misc cleanup<commit_after># Convenience methods consumed in the dashboards controller index view
module DashboardsHelper
  def week_range(date: DateTime.now.in_time_zone, start_day: :monday)
    week_start = date.beginning_of_week start_day
    week_end = date.end_of_week start_day
    week_start_string = week_start.strftime('%B %-d')
    week_end_string = if week_start.month == week_end.month
                        week_end.strftime('%-d')
                      else
                        week_end.strftime('%B %-d')
                      end
    "#{week_start_string} - #{week_end_string}"
  end

  def voicemail_options
    enum_text = { not_specified: 'No instructions; no ID VM',
                  no: 'Do not leave a voicemail',
                  yes: 'Voicemail OK, ID OK' }
    vm_options = Patient::VOICEMAIL_PREFERENCE

    vm_options.map { |option| [enum_text[option], option] }
  end

  def remove_from_call_list_glyphicon
    safe_join [
      tag(:span, class: ['glyphicon', 'glyphicon-remove'], aria: { hidden: true }),
      tag(:span, class: ['sr-only'], text: 'Remove call')
    ]
  end

  def call_glyphicon
    safe_join [
      tag(:span, class: ['glyphicon', 'glyphicon-earphone'], aria: { hidden: true }),
      tag(:span, class: ['sr-only'], text: 'Call')
    ]
  end

  def th_autosortable(column_name, type, local_assigns)
    # Throw a flag unless sorting by string, int, or float
    raise 'Bad datatype' unless %w(string string-ins int float).include? type
    content_tag :th, data: { sort: type } do
      safe_join([column_name, autosort_arrow_span(local_assigns)], ' ').strip
    end
  end

  private

  # span that holds the up/down arrow
  def autosort_arrow_span(local_assigns)
    return '' unless local_assigns[:autosortable]
    content_tag(:span, '[-]', class: 'arrow')
  end
end
{'fraction_non_alphanumeric': 0.11367380560131796, 'fraction_numerical': 0.0, 'mean_word_length': 2.9426406926406927, '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': '5264009', 'n_tokens_mistral': 1215, 'n_tokens_neox': 1166, 'n_words': 297}