<commit_before>class FbesPlugin::ResponsaController < PublicController

  def initiatives
    @last_updated_on = params[:last_updated_on] || 24
    @last_updated_on = @last_updated_on.months.ago

    @enterprises = environment.enterprises.enabled.joins(:products, :articles).
      where('profiles.updated_at > ? OR products.updated_at > ? OR articles.updated_at > ?', @last_updated_on, @last_updated_on, @last_updated_on).
      uniq.group('profiles.id')
    @consumers_coops = environment.communities.joins(:orders).
      where('orders_plugin_orders.updated_at > ?', @last_updated_on).
      uniq.group('profiles.id')

    @results = @enterprises + @consumers_coops

    @json = @results.map do |r|
      r.description ||= if r.is_a? Enterprise then 'Empreendimento de Economia Solidária' else 'Grupo de Consumo Responsável' end
      {
        local_id: r.id,
        url: url_for(r.url),
        title: r.short_name(nil),
        description: r.description,
        lat: r.lat,
        lng: r.lng,
        address: [r.address, r.address_line2, r.district, r.zip_code].select{ |f| f.present? }.join(', '),
        city: r.city,
        state: r.state,
        country: 'BR',
        created_at: r.created_at,
        updated_at: r.updated_at,
        avatar: if r.image then "#{environment.top_url}#{r.image.public_filename}" else nil end,
      }.compact
    end

    render json: Oj.dump(@json, mode: :compat)
  end

  protected

  def default_url_options
    # avoid rails' use_relative_controller!
    {use_route: '/'}
  end

end
<commit_msg>fbes: there is no compact for hashs<commit_after>class FbesPlugin::ResponsaController < PublicController

  def initiatives
    @last_updated_on = params[:last_updated_on] || 24
    @last_updated_on = @last_updated_on.months.ago

    @enterprises = environment.enterprises.enabled.joins(:products, :articles).
      where('profiles.updated_at > ? OR products.updated_at > ? OR articles.updated_at > ?', @last_updated_on, @last_updated_on, @last_updated_on).
      uniq.group('profiles.id')
    @consumers_coops = environment.communities.joins(:orders).
      where('orders_plugin_orders.updated_at > ?', @last_updated_on).
      uniq.group('profiles.id')

    @results = @enterprises + @consumers_coops

    @json = @results.map do |r|
      r.description ||= if r.is_a? Enterprise then 'Empreendimento de Economia Solidária' else 'Grupo de Consumo Responsável' end
      {
        local_id: r.id,
        url: url_for(r.url),
        title: r.short_name(nil),
        description: r.description,
        lat: r.lat,
        lng: r.lng,
        address: [r.address, r.address_line2, r.district, r.zip_code].select{ |f| f.present? }.join(', '),
        city: r.city,
        state: r.state,
        country: 'BR',
        created_at: r.created_at,
        updated_at: r.updated_at,
        avatar: if r.image then "#{environment.top_url}#{r.image.public_filename}" else nil end,
      }.tap{ |h| h.delete_if{ |k, v| k.nil? } }
    end

    render json: Oj.dump(@json, mode: :compat)
  end

  protected

  def default_url_options
    # avoid rails' use_relative_controller!
    {use_route: '/'}
  end

end

{'fraction_non_alphanumeric': 0.12840837032339886, 'fraction_numerical': 0.0019023462270133164, 'mean_word_length': 3.1080729166666665, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '4154043', 'n_tokens_mistral': 1101, 'n_tokens_neox': 1064, 'n_words': 219}