2018-08-03 03:15:25 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-06-07 04:04:55 -04: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 11:09:44 -04:00
|
|
|
rescue ActiveModel::MissingAttributeError
|
|
|
|
model.reset.raw_data
|
2018-06-07 04:04:55 -04:00
|
|
|
end
|
|
|
|
|
2020-07-22 11:09:28 -04: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-27 20:10:34 -04:00
|
|
|
set_data(model, new_data)
|
2020-07-22 11:09:28 -04:00
|
|
|
model.raw_data.to_s.bytesize
|
|
|
|
end
|
|
|
|
|
|
|
|
def size(model)
|
|
|
|
data(model).to_s.bytesize
|
2018-06-07 04:04:55 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def delete_data(model)
|
|
|
|
model.update_columns(raw_data: nil) unless model.raw_data.nil?
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|