-
Notifications
You must be signed in to change notification settings - Fork 0
Santa Coin useful queries
Pietro edited this page Jul 31, 2018
·
1 revision
This is a list of useful Queries for getting data realted to Santarcangelo Festival 2018
Setup
santarcangelo = Group.find ID
santacoin = Currency.find ID
# To avoid database logs
old_logger = ActiveRecord::Base.logger
ActiveRecord::Base.logger = nil
Total # of Sellers (used also for other roles)
Membership.where(group: santarcangelo, role: 'editor').count
# of SC Wallets with at least 1 transaction (including sellers’ and issuer’s wallets)
Wallet.where(currency: santacoin).select{|wallet| wallet.transactions.count > 0}.count
Total # of SC transactions
Transaction.select {|t| t.to_wallet.currency == santacoin}.count
Total SC amount exchanged
Transaction.select {|t| t.to_wallet.currency == santacoin}.map(&:amount).reduce(&:+).to_f