Sha256: dcc8b63ad80e56b28d9a5e10cce7297346a65cd5c735e3341be0fe35e402dae3

Contents?: true

Size: 1.33 KB

Versions: 11

Compression:

Stored size: 1.33 KB

Contents

# frozen_string_literal: true

class BenchmarkController < ApplicationController
  def normal_html
    @complex_data = generate_complex_data
  end

  def ruby_2html
    @complex_data = generate_complex_data
  end

  private
    def generate_complex_data
      {
        users: 50.times.map do |i|
          {
            id: i + 1,
            name: Faker::Name.name,
            email: Faker::Internet.email,
            address: {
              street: Faker::Address.street_address,
              city: Faker::Address.city,
              country: Faker::Address.country
            },
            orders: rand(1..5).times.map do
              {
                id: Faker::Alphanumeric.alphanumeric(number: 10),
                total: Faker::Commerce.price(range: 10..1000.0),
                items: rand(1..10).times.map do
                  {
                    name: Faker::Commerce.product_name,
                    price: Faker::Commerce.price(range: 5..500.0),
                    quantity: rand(1..5)
                  }
                end
              }
            end
          }
        end,
        stats: {
          total_users: 50,
          average_orders_per_user: rand(1.0..5.0).round(2),
          most_expensive_item: Faker::Commerce.product_name,
          most_popular_country: Faker::Address.country
        }
      }
    end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
ruby2html-1.5.3 app/controllers/benchmark_controller.rb
ruby2html-1.5.2 app/controllers/benchmark_controller.rb
ruby2html-1.5.1 app/controllers/benchmark_controller.rb
ruby2html-1.5.0 app/controllers/benchmark_controller.rb
ruby2html-1.4.0 app/controllers/benchmark_controller.rb
ruby2html-1.3.3 app/controllers/benchmark_controller.rb
ruby2html-1.3.2 app/controllers/benchmark_controller.rb
ruby2html-1.3.1 app/controllers/benchmark_controller.rb
ruby2html-1.3.0 app/controllers/benchmark_controller.rb
ruby2html-1.2.0 app/controllers/benchmark_controller.rb
ruby2html-1.1.0 app/controllers/benchmark_controller.rb