module Api
  class Version1Controller < ActionController::Base
    before_filter :set_site
    
    def get_proxy
      older_than = (params[:older_than] || -1).to_i
      result = @site.select_proxy(older_than)
      if result == Proxy::NoProxy
        render json: Responses::try_again
      elsif result.is_a? Proxy::NoColdProxy
        render json: Responses::try_again(result.timeout)
      else
        render json: Responses::success(result)
      end
    end
    
    def report_result
      begin
        @proxy = Proxy.find(params[:proxy_id])
        if params[:succeeded]
          @site.proxy_succeeded! @proxy
        else
          @site.proxy_failed! @proxy
        end
      rescue ActiveRecord::RecordNotFound => e
        # Swallow not-found-type errors
      end
      render json: Responses::success
    end
    
    private
    def set_site
      @site = Site.find_or_create_by(name: params[:site_name])
    end
  end
end
module Api
  class Version1Controller < ActionController::Base
    before_filter :set_site
    
    def get_proxy
      result = @site.select_proxy(params[:older_than])
      if result == Proxy::NoProxy
        render json: Response::try_again
      elsif result.is_a? Proxy::NoColdProxy
        render json: Response::try_again(result.timeout)
      else
        render json: Response::success(result)
      end
    end
    
    def report_result
      begin
        @proxy = Proxy.find(params[:proxy_id])
        if params[:succeeded]
          @site.proxy_succeeded! @proxy
        else
          @site.proxy_failed! @proxy
        end
      rescue ActiveRecord::RecordNotFound => e
        # Swallow not-found-type errors
      end
      render json: Response::success
    end
    
    private
    def set_site
      @site = Site.find_or_create_by(name: params[:site_name])
    end
  end
end
--- 
+++ 
@@ -3,13 +3,14 @@
     before_filter :set_site
     
     def get_proxy
-      result = @site.select_proxy(params[:older_than])
+      older_than = (params[:older_than] || -1).to_i
+      result = @site.select_proxy(older_than)
       if result == Proxy::NoProxy
-        render json: Response::try_again
+        render json: Responses::try_again
       elsif result.is_a? Proxy::NoColdProxy
-        render json: Response::try_again(result.timeout)
+        render json: Responses::try_again(result.timeout)
       else
-        render json: Response::success(result)
+        render json: Responses::success(result)
       end
     end
     
@@ -24,7 +25,7 @@
       rescue ActiveRecord::RecordNotFound => e
         # Swallow not-found-type errors
       end
-      render json: Response::success
+      render json: Responses::success
     end
     
     private
Fix NameError and parameter handling
