[refs #374] Add unixtime search and output. Fix rate limit configuration and 404 status

This commit is contained in:
konstantin.grabar 2012-09-05 17:47:25 +04:00
parent 58d9a972ef
commit b9a622acec
8 changed files with 17 additions and 9 deletions

View File

@ -14,7 +14,7 @@ class Api::V1::BuildListsController < Api::V1::BaseController
def create
project = Project.find(params[:build_list][:project_id])
save_to_repository = Repository.find params[:build_list][:save_to_repository_id]
save_to_repository = Repository.find params[:build_list][:save_to_repository_id] #FIXME
params[:build_list][:save_to_platform_id] = save_to_repository.platform_id
build_list = project.build_lists.build(params[:build_list])

View File

@ -34,7 +34,7 @@ class ApplicationController < ActionController::Base
ActionController::UnknownController,
ActionController::UnknownAction do |exception|
respond_to do |format|
format.json { render :json => {:message => t("flash.404_message")}.to_json }
format.json { render :json => {:message => t("flash.404_message")}.to_json, :status => 404 }
format.html { redirect_to '/404.html', :alert => t("flash.404_message") }
end
end

View File

@ -68,7 +68,9 @@ class BuildList::Filter
end
def build_date_from_params(field_name, params)
if params["#{field_name}(1i)"].present? || params["#{field_name}(2i)"].present? || params["#{field_name}(3i)"].present?
if params[field_name].present?
Time.at(params[field_name].to_i)
elsif params["#{field_name}(1i)"].present? || params["#{field_name}(2i)"].present? || params["#{field_name}(3i)"].present?
Date.civil((params["#{field_name}(1i)"].presence || Date.today.year).to_i,
(params["#{field_name}(2i)"].presence || Date.today.month).to_i,
(params["#{field_name}(3i)"].presence || Date.today.day).to_i)

View File

@ -1,5 +1,7 @@
json.platform do |json|
json.(@platform, :id, :name, :description, :parent_platform_id, :created_at, :updated_at, :released, :visibility, :platform_type, :distrib_type)
json.(@platform, :id, :name, :description, :parent_platform_id, :released, :visibility, :platform_type, :distrib_type)
json.created_at @platform.created_at.to_i
json.updated_at @platform.updated_at.to_i
json.owner do |json_owner|
json_owner.(@platform.owner, :id, :name)
json_owner.type @platform.owner_type

View File

@ -1,7 +1,9 @@
json.project do |json|
json.(@project, :id, :name, :created_at, :updated_at, :visibility, :description, :ancestry, :has_issues, :has_wiki,
json.(@project, :id, :name, :visibility, :description, :ancestry, :has_issues, :has_wiki,
:srpm_file_name, :srpm_content_type, :srpm_file_size, :srpm_updated_at, :default_branch, :is_package,
:average_build_time, :build_count)
json.created_at @project.created_at.to_i
json.updated_at @project.updated_at.to_i
json.owner do |json_owner|
json_owner.(@project.owner, :id, :name)
json_owner.type @project.owner_type

View File

@ -1,5 +1,7 @@
json.repository do |json|
json.(@repository, :id, :name, :created_at, :updated_at, :description)
json.(@repository, :id, :name, :description)
json.created_at @repository.created_at.to_i
json.updated_at @repository.updated_at.to_i
json.platform do |json_platform|
json_platform.(@repository.platform, :id, :name)
json_platform.url api_v1_platform_path(@repository.platform, :format => :json)

View File

@ -16,9 +16,9 @@ end
module Rosa
class Application < Rails::Application
# Rate limit
config.middleware.use Rack::Throttle::Interval, :cache => Redis.new, :key_prefix => :throttle, :min => 3.0
config.middleware.use Rack::Throttle::Interval, :cache => Redis.new, :key_prefix => :throttle, :min => 0.1
config.middleware.use Rack::Throttle::Hourly, :max => 100
config.middleware.use Rack::Throttle::Daily, :max => 5000
config.middleware.use Rack::Throttle::Daily, :max => 500
config.action_view.javascript_expansions[:defaults] = %w(jquery rails)
config.autoload_paths += %W(#{config.root}/lib)

View File

@ -136,7 +136,7 @@ en:
exception_message: Access violation to this page!
500_message: Error 500. Something went wrong. We've been notified about this issue and we'll take a look at it shortly.
404_message: Error 404. Page not found!
404_message: Error 404. Resource not found!
collaborators:
successfully_changed: Collaborators list successfully changed