-
Notifications
You must be signed in to change notification settings - Fork 0
Oltrino useful queries
Pietro edited this page Jun 3, 2019
·
4 revisions
This is a list of useful queries for getting data related to OltrEconomia Festival 2019
Setup
oef = Group.find ID
oltrino = Currency.find ID
# To avoid database logs
old_logger = ActiveRecord::Base.logger
ActiveRecord::Base.logger = nilTotal # of Sellers (used also for other roles)
Membership.where(group: oef, role: 'editor').count# of ◎ Wallets with at least 1 transaction (including sellers’ and issuer’s wallets)
Wallet.where(currency: oltrino).select{|wallet| wallet.transactions.count > 0}.countTotal # of ◎ transactions
Transaction.select {|t| t.to_wallet.currency == oltrino}.countTotal ◎ amount exchanged
Transaction.select {|t| t.to_wallet.currency == oltrino}.map(&:amount).reduce(&:+).to_f