2018-08-03 07:15:25 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-06-07 08:04:55 +00:00
|
|
|
module Ci
|
|
|
|
module BuildTraceChunks
|
|
|
|
class Database
|
|
|
|
def available?
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
def keys(relation)
|
|
|
|
[]
|
|
|
|
end
|
|
|
|
|
|
|
|
def delete_keys(keys)
|
|
|
|
# no-op
|
|
|
|
end
|
|
|
|
|
|
|
|
def data(model)
|
|
|
|
model.raw_data
|
2020-09-28 15:09:44 +00:00
|
|
|
rescue ActiveModel::MissingAttributeError
|
|
|
|
model.reset.raw_data
|
2018-06-07 08:04:55 +00:00
|
|
|
end
|
|
|
|
|
2020-07-22 15:09:28 +00:00
|
|
|
def set_data(model, new_data)
|
|
|
|
model.raw_data = new_data
|
|
|
|
end
|
|
|
|
|
|
|
|
def append_data(model, new_data, offset)
|
|
|
|
if offset > 0
|
|
|
|
truncated_data = data(model).to_s.byteslice(0, offset)
|
|
|
|
new_data = truncated_data + new_data
|
|
|
|
end
|
|
|
|
|
2020-08-28 00:10:34 +00:00
|
|
|
set_data(model, new_data)
|
2020-07-22 15:09:28 +00:00
|
|
|
model.raw_data.to_s.bytesize
|
|
|
|
end
|
|
|
|
|
|
|
|
def size(model)
|
|
|
|
data(model).to_s.bytesize
|
2018-06-07 08:04:55 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def delete_data(model)
|
|
|
|
model.update_columns(raw_data: nil) unless model.raw_data.nil?
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|