Class: SteemData::Account

Inherits:
Object
  • Object
show all
Includes:
Mongoid::Attributes::Dynamic, Mongoid::Document, ActsAsMathematical, ActsAsTemporal
Defined in:
lib/steem_data/account.rb

Instance Method Summary collapse

Methods included from ActsAsTemporal

included

Methods included from ActsAsMathematical

included

Instance Method Details

#follower_accountsObject



18
# File 'lib/steem_data/account.rb', line 18

def follower_accounts; .where(:name.in => followers); end

#following_accountsObject



17
# File 'lib/steem_data/account.rb', line 17

def following_accounts; .where(:name.in => following); end

#postsObject



19
# File 'lib/steem_data/account.rb', line 19

def posts; Post.where(author: name); end

#proxiedObject



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).
   = 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.
  .each do |b|
    if b.proxy == name
      proxied += [b.]
    else
      proxied -= [b.]
    end
    
    proxied = proxied.uniq
  end
  
  proxied
end

#proxied_accountsObject



20
# File 'lib/steem_data/account.rb', line 20

def proxied_accounts; .where(:name.in => proxied); end

#routedObject



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. == name && b.percent > 0
      routed += [b.]
    else
      routed -= [b.]
    end
    
    routed = routed.uniq
  end
  
  routed
end

#routed_accountsObject



21
# File 'lib/steem_data/account.rb', line 21

def routed_accounts; .where(:name.in => routed); end