Class: SteemData::Account
- Inherits:
-
Object
- Object
- SteemData::Account
- Includes:
- Mongoid::Attributes::Dynamic, Mongoid::Document, ActsAsMathematical, ActsAsTemporal
- Defined in:
- lib/steem_data/account.rb
Instance Method Summary collapse
- #follower_accounts ⇒ Object
- #following_accounts ⇒ Object
- #posts ⇒ Object
- #proxied ⇒ Object
- #proxied_accounts ⇒ Object
- #routed ⇒ Object
- #routed_accounts ⇒ Object
Methods included from ActsAsTemporal
Methods included from ActsAsMathematical
Instance Method Details
#follower_accounts ⇒ Object
18 |
# File 'lib/steem_data/account.rb', line 18 def follower_accounts; Account.where(:name.in => followers); end |
#following_accounts ⇒ Object
17 |
# File 'lib/steem_data/account.rb', line 17 def following_accounts; Account.where(:name.in => following); end |
#posts ⇒ Object
19 |
# File 'lib/steem_data/account.rb', line 19 def posts; Post.where(author: name); end |
#proxied ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/steem_data/account.rb', line 23 def proxied proxied = [] # List of accounts that have used this account as a proxy. accounts = AccountOperation.type('account_witness_proxy').where(proxy: name). distinct(:account) - [name] # Related operations (either voting for this account or resetting). account_witness_proxies = AccountOperation.type('account_witness_proxy'). where(:account.in => accounts, :proxy.in => ['', name]). order_by(timestamp: :asc) # Replay the proxy selection related to this account. Note, this # iteration will even work if the full proxy history is replayed, because # we are only looking for "this account" or "not this account" in the # order that those operations appear on the blockchain. account_witness_proxies.each do |b| if b.proxy == name proxied += [b.account] else proxied -= [b.account] end proxied = proxied.uniq end proxied end |
#proxied_accounts ⇒ Object
20 |
# File 'lib/steem_data/account.rb', line 20 def proxied_accounts; Account.where(:name.in => proxied); end |
#routed ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/steem_data/account.rb', line 52 def routed routed = [] # List of accounts that have used this account to route withrdrawn vests. accounts = AccountOperation.type('set_withdraw_vesting_route').where(to_account: name). distinct(:account) - [name] # Related operations (either setting this account or resetting). routes = AccountOperation.type('set_withdraw_vesting_route'). where(:account.in => accounts, to_account: name). order_by(timestamp: :asc) # Like proxied, we replay the proxy selection related to this account. routes.each do |b| if b.to_account == name && b.percent > 0 routed += [b.account] else routed -= [b.account] end routed = routed.uniq end routed end |
#routed_accounts ⇒ Object
21 |
# File 'lib/steem_data/account.rb', line 21 def routed_accounts; Account.where(:name.in => routed); end |