Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions frameworks/sinatra/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,14 @@ class App < Sinatra::Base

items = rows.map do |row|
{
id: row['id'],
name: row['name'],
category: row['category'],
price: row['price'],
quantity: row['quantity'],
active: row['active'] == 1,
tags: JSON.parse(row['tags']),
rating: { score: row['rating_score'], count: row['rating_count'] }
id: row[:id],
name: row[:name],
category: row[:category],
price: row[:price],
quantity: row[:quantity],
active: row[:active] == 1,
tags: JSON.parse(row[:tags]),
rating: { score: row[:rating_score], count: row[:rating_count] }
}
end
render_json JSON.generate(items: items, count: items.length)
Expand All @@ -141,6 +141,7 @@ def self.get_async_db
max_connections = ENV.fetch('MAX_THREADS', 4).to_i + ENV.fetch("MAX_IO_THREADS", 10).to_i
ConnectionPool.new(size: max_connections, timeout: 5) do
db = PG.connect(ENV['DATABASE_URL'])
db.field_name_type = :symbol
db.prepare('select', PG_QUERY)
db
end
Expand Down