This query response contains a delta pair that is computed so that I don't have to unnecessarily create another column in the database.
records = [
{"credential_id"=>1, "followers_count"=>10000, "created_at"=>"2017-02-26 18:50:20.654996", "delta"=>nil},
{"credential_id"=>1, "followers_count"=>12000, "created_at"=>"2017-02-27 18:50:20.654996", "delta"=>2000},
{"credential_id"=>1, "followers_count"=>15000, "created_at"=>"2017-02-28 18:50:20.654996", "delta"=>3000}
]
Desired result:
deltas = [
[2017-02-26 18:50:20.654996, nil],
[2017-02-27 18:50:20.654996, 2000],
[2017-02-28 18:50:20.654996, 3000]
]
Attempts -- However, I think the fact that :delta is not part of the model/table is preventing me from using the following solutions: .pluck(:created_at, :delta), .values_at("created_at", "delta"), and
attributes = [:created_at, :delta]
records.map do |record|
attributes.map { |attr| record[attr] }
end
I've run out of solutions to try. Can you help me find the desired result?