lib/cellect/server/adapters/postgres.rb in cellect-server-0.1.0 vs lib/cellect/server/adapters/postgres.rb in cellect-server-0.1.1

- old
+ new

@@ -9,12 +9,21 @@ @pg ||= ConnectionPool.new(size: ENV.fetch('PG_POOL_SIZE', 25).to_i) do PG.connect connection_options end end - def workflow_list + def workflow_list(*names) with_pg do |pg| - pg.exec('SELECT * FROM workflows').collect do |row| + statement = 'SELECT * FROM workflows' + statement += case names.length + when 0 + "" + when 1 + "WHERE \"workflows\".\"id\" = #{ names.first }" + else + "WHERE \"workflows\".\"id\" IN (#{ names.join(',') })" + end + pg.exec(statement).collect do |row| { 'id' => row['id'].to_i, 'name' => row['id'], 'prioritized' => row['prioritized'] == 't', 'pairwise' => row['pairwise'] == 't',