def spread_stats    
      @items = basic_collection.between_dates(@stat_from, @stat_thru)
      
      handle_special_fields
       
      data = {
        alternatives: [
          {
            type: 'spread'
          },
          {
            type: 'process',
            uri: url_for(action: "process_stats", field: params[:field], filters: params[:filters], only_path: true)
          }
        ],   
        from: @stat_from.to_time.utc.to_i * 1000,
        thru: @stat_thru.to_time.utc.to_i * 1000,
        total: @items.count(:id),
        data: @items.count_by(params[:field])
      }
      
      if further_details.keys.include? params[:field]
        filters = (params[:filters] || {})
        filters[params[:field]] = '%{self}'
        
        data[:detail_uri] = url_for(action: "spread_stats", field: further_details[params[:field]], filters: filters, only_path: true)
      end
      
      render json: data
    end
def spread_stats    
      @items = basic_collection.between_dates(@stat_from, @stat_thru)
      
      handle_special_fields
       
      data = {
        alternatives: [
          {
            type: 'spread'
          },
          {
            type: 'process',
            uri: url_for(action: "process_stats", field: params[:field], filters: params[:filters], only_path: true)
          }
        ],   
        from: @stat_from.to_time.utc.to_i * 1000,
        thru: @stat_thru.to_time.utc.to_i * 1000,
        total: @items.count(:id),
        data: @items.count_by(params[:field])
      }
      
      if further_details.keys.include? params[:field]
        filters = (params[:filters] || {})
        filters[params[:field]] = '%{self}'
        
        data[:detail_uri] = url_for(action: "spread_stats", field: further_details[params[:field]], filters: filters, only_path: true)
      end
      
      render json: data
    end
This action generates a JSON for a spread statistics.