Skip to content

Instantly share code, notes, and snippets.

Avatar
💻
Learning at Codeable

Andrés Del Carpio andres-dc

💻
Learning at Codeable
View GitHub Profile
View cli.rb
def initialize
@conn = PG.connect(dbname: 'restaurants')
end
def unique_dishes
response = @conn.exec(%(SELECT name FROM dishes ORDER BY name ASC;)).to_a
query_to_table(response)
end
def user_distribution(group_value)
View filtered_list.rb
def filtered_list(filter_name, filter_value)
puts "#{filter_name} - #{filter_value}"
query = %(SELECT name, type, city FROM restaurants\n)
if filter_name.nil? && filter_value.nil?
query << "ORDER BY name ASC;"
else
query << %(WHERE LOWER(#{filter_name}) LIKE '%#{filter_value}%' ORDER BY name ASC;)
end
You can’t perform that action at this time.