update log find method, log db connection, add logs_db default config
This commit is contained in:
parent
cd12ba5402
commit
1691119142
|
@ -1,6 +1,6 @@
|
|||
module Travis::API::V3
|
||||
class Models::Log < Model
|
||||
establish_connection 'logs_database'
|
||||
class Models::Log < Model
|
||||
establish_connection(Travis.config.logs_database)
|
||||
belongs_to :job
|
||||
belongs_to :removed_by, class_name: 'User', foreign_key: :removed_by
|
||||
has_many :log_parts, dependent: :destroy
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
module Travis::API::V3
|
||||
class Models::LogPart < Model
|
||||
establish_connection 'logs_database'
|
||||
establish_connection(Travis.config.logs_database)
|
||||
belongs_to :log
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,9 +5,9 @@ module Travis::API::V3
|
|||
|
||||
def find(job)
|
||||
#check for the log in the Logs DB
|
||||
log = Models::Log.find_by_job_id
|
||||
log = Models::Log.find_by_job_id(job.id)
|
||||
#if the log exists and has not been archived yet, then collect the log_parts and return the Log query object
|
||||
unless !log.archived_at.nil?
|
||||
if !log.archived_at.nil?
|
||||
log_parts = Models::LogPart.where(log_id: log.id).to_a
|
||||
elsif log.archived_at?
|
||||
## if it's not there then fetch it from S3, and return it wrapped as a compatible log_parts object with a hard coded #number (log_parts have a number) and the parts chunked (not sure how to do this)
|
||||
|
|
|
@ -18,6 +18,7 @@ module Travis
|
|||
assets: { host: HOSTS[Travis.env.to_sym] },
|
||||
amqp: { username: 'guest', password: 'guest', host: 'localhost', prefetch: 1 },
|
||||
database: { adapter: 'postgresql', database: "travis_#{Travis.env}", encoding: 'unicode', min_messages: 'warning', variables: { statement_timeout: 10_000 } },
|
||||
logs_database: { adapter: 'postgresql', database: "travis_logs_#{Travis.env}", encoding: 'unicode', min_messages: 'warning', variables: { statement_timeout: 10_000 } },
|
||||
s3: { access_key_id: '', secret_access_key: '' },
|
||||
pusher: { app_id: 'app-id', key: 'key', secret: 'secret' },
|
||||
sidekiq: { namespace: 'sidekiq', pool_size: 1 },
|
||||
|
|
|
@ -10,9 +10,8 @@ describe Travis::API::V3::Services::Log::Find, set_app: true do
|
|||
let(:parsed_body) { JSON.load(body) }
|
||||
|
||||
context 'when log stored in db' do
|
||||
describe 'returns log as plain text' do
|
||||
describe 'returns log as array of Log Parts' do
|
||||
let(:log) { job.log }
|
||||
|
||||
before { get("/v3/job/#{job.id}/log", {}, headers) }
|
||||
|
||||
example { expect(last_response).to be_ok }
|
||||
|
|
Loading…
Reference in New Issue
Block a user