class DynamicModelGenerator
  def self.create_model(interval)
    class_name = "Ln#{interval.capitalize}Data" 
    collection_name = "ln_aggregate_#{interval}_data" 
    unless Object.const_defined?(class_name)
      Object.const_set(class_name, Class.new do
        include Mongoid::Document

        field :st, type: Integer # Slot start time
        field :tx_u, type: Integer
        field :tx_r, type: Integer
        field :rx_u, type: Integer
        field :rx_r, type: Integer
        field :clients, type: Hash, default: {}
        field :managed_clients_count, type: Integer
        field :lan_count, type: Integer
        field :wireless_count, type: Integer
        field :down_clients, type: Integer
        field :lan_unused, type: Integer
        field :device_details, type: Hash, default: {}
        field :switch_model, type: Hash, default: {}
        field :ap_model, type: Hash, default: {}
        field :uplink_total_count,  type: Hash, default: {}
        field :grouped_uplinks, type: Hash, default: {}  #grouped_uplinks: {"1"=>[true, "active"], "4"=>[false, "ready"]}
        field :uplink_info_array, type: Array, default: [] #uplink_info_array: [{"16500"=>["1", true, "active"]}, {"16501"=>["4", false, "ready"]}]
        field :isp, type: String
        field :enabled_ssid, type: Integer
        field :wan_cell_count, type: Integer
        field :status, type: String
        field :isp_outages, type: Integer
        field :org_id, type: Integer
        field :ln, type: Integer
        field :networks_affected, type: Integer
        field :last_24_health,type: Array, default: []
        field :network_name, type: String 
        field :template_name, type: String 
        field :overall_health_last24hr, type: Float
        field :primary_uplink_status, type: Integer 


        store_in collection: collection_name
      end)
    end
  end
end

DynamicModelGenerator.create_model("5m")