<commit_before>module GroupedTimeZones
  module ViewHelpers
    def  grouped_time_zone_select(name, attribute, record=nil, force_uniq=false)
      select_tag("#{name}[#{attribute}]", grouped_options_for_select(grouped_time_zones(force_uniq), (record ? record.send(attribute.to_sym) : nil)))
    end

    def grouped_time_zones(force_uniq=false)
      us_zones      = ActiveSupport::TimeZone.us_zones
      non_us_zones  = other_zones(us_zones, force_uniq)
      zone_options  = lambda do |zones|
        zones.map { |tz| [tz.to_s, tz.tzinfo.identifier] }
      end
      return [['United States', zone_options.call(us_zones)], ['Other', zone_options.call(non_us_zones)]]
    end

    private

    def other_zones(excluded_zones, force_uniq=false)
      other_zones = force_uniq ? ActiveSupport::TimeZone.all.reject{|tz| tz.name =~ %r{/} }.uniq{|tz| tz.tzinfo.identifier } : ActiveSupport::TimeZone.all.reject{|tz| tz.name =~ %r{/} }
      other_zones.sort - excluded_zones
    end
  end
end<commit_msg>Cleaned up code which creates the unique zones.<commit_after>module GroupedTimeZones
  module ViewHelpers
    def  grouped_time_zone_select(name, attribute, record=nil, force_uniq=false)
      select_tag("#{name}[#{attribute}]", grouped_options_for_select(grouped_time_zones(force_uniq), (record ? record.send(attribute.to_sym) : nil)))
    end

    def grouped_time_zones(force_uniq=false)
      us_zones      = ActiveSupport::TimeZone.us_zones
      non_us_zones  = other_zones(us_zones, force_uniq)
      zone_options  = lambda do |zones|
        zones.map { |tz| [tz.to_s, tz.tzinfo.identifier] }
      end
      return [['United States', zone_options.call(us_zones)], ['Other', zone_options.call(non_us_zones)]]
    end

    private

    def other_zones(excluded_zones, force_uniq=false)
      other_zones = ActiveSupport::TimeZone.all.reject{|tz| tz.name =~ %r{/} }
      other_zones.uniq!{|tz| tz.tzinfo.identifier } if force_uniq
      other_zones.sort - excluded_zones
    end
  end
end
{'fraction_non_alphanumeric': 0.1186780170255383, 'fraction_numerical': 0.0, 'mean_word_length': 4.123076923076923, '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': '2750146', 'n_tokens_mistral': 730, 'n_tokens_neox': 709, 'n_words': 118}