add builds

This commit is contained in:
carlad 2015-08-21 13:38:07 +02:00
parent 69a4a0a735
commit fe9a6536d7
5 changed files with 32 additions and 0 deletions

View File

@ -0,0 +1,13 @@
module Travis::API::V3
class Queries::Builds < Query
def find(repository)
repository.builds
end
def count(repository, time_frame)
find(repository).
where(event_type: 'api'.freeze, result: 'accepted'.freeze).
where('created_at > ?'.freeze, time_frame.ago).count
end
end
end

View File

@ -0,0 +1,6 @@
module Travis::API::V3
class Renderer::Builds < Renderer::CollectionRenderer
type :builds
collection_key :builds
end
end

View File

@ -39,6 +39,11 @@ module Travis::API::V3
get :for_current_user get :for_current_user
end end
resource :builds do
route '/builds'
get :find
end
resource :build do resource :build do
capture id: :digit capture id: :digit
route '/build/{build.id}' route '/build/{build.id}'

View File

@ -5,6 +5,7 @@ module Travis::API::V3
Accounts = Module.new { extend Services } Accounts = Module.new { extend Services }
Branch = Module.new { extend Services } Branch = Module.new { extend Services }
Build = Module.new { extend Services } Build = Module.new { extend Services }
Builds = Module.new { extend Services }
Organization = Module.new { extend Services } Organization = Module.new { extend Services }
Organizations = Module.new { extend Services } Organizations = Module.new { extend Services }
Owner = Module.new { extend Services } Owner = Module.new { extend Services }

View File

@ -0,0 +1,7 @@
module Travis::API::V3
class Services::Builds::Find < Service
def run!
find(:builds, find(:repository))
end
end
end