travis-api/lib/travis/api/app/service/builds.rb
2012-07-18 14:56:41 +02:00

28 lines
708 B
Ruby

module Travis
module Api
class App
class Service
class Builds < Service
def collection
scope = repository.builds.by_event_type(params[:event_type] || 'push')
scope = params[:after] ? scope.older_than(params[:after]) : scope.recent
scope
end
def element
one = params[:repository_id] ? repository.builds : Build
one.includes(:commit, :matrix => [:commit, :log]).find(params[:id])
end
private
def repository
Repository.find_by(params) || not_found # TODO needs to return nil if params are empty
end
end
end
end
end
end