class Hive::Account
To find an {Hive::Account}, use the following idiom:
alice = Hive::Account.find_by_name 'alice'
An account has many {Hive::Post} records. To access associated posts, use:
alice.posts
Like posts, account has many {Hive::PostsCache} records. There are two ways to access an account's related {Hive::PostsCache} records.
alice.posts.joins(:cache) # which includes posts_cache fields alice.posts_cache # automatically joins posts to get posts_cache
An account also has many {Hive::Reblog} records that can be used to access reblogged posts, which are the posts that the account has reblogged (aka re-steemed):
alice.reblogged_posts
Accounts also have access to {Hive::Follow} for various things like “follow” and “mute”.
alice.following # accounts that this account is following alice.followers # accounts that follow this account alice.muting # accounts that this account is muting alice.muters # accounts that mute this account
Post
promotions are tracked by {Hive::Payment} and associated with accounts as well. To get a list of posts that this account has promoted:
alice.promoted_posts
Also, you can get a list of all accounts that this account has promoted at some point.
alice.promoted_authors
This is the sum of all post promotion by this account, grouped by the author being promoted:
puts JSON.pretty_generate alice.payments. joins(:post).group(:author).sum(:amount)
This scope will limit the number of accounts to those who have only ever posted n times:
Hive::Account.root_posts_count(1) Hive::Account.root_posts_count(1..5) # accounts with between 1 and 5 posts
Public Instance Methods
The entire feed for this account, as in, all content created/reblogged by authors that this account follows.
@return {ActiveRecord::Relation}
# File lib/hive/models/account.rb, line 120 def feed; Post.feed(following); end
The entire feed for this account, as in, all content created/reblogged by authors that this account follows.
@return {ActiveRecord::Relation}
# File lib/hive/models/account.rb, line 114 def feed_cache; Post.feed_cache(following); end
The entire ignred feed for this account, as in, all content created/reblogged by authors that this account mutes.
@return {ActiveRecord::Relation}
# File lib/hive/models/account.rb, line 132 def ignored_feed; Post.feed(muting); end
The entire ignred feed for this account, as in, all content created/reblogged by authors that this account mutes.
@return {ActiveRecord::Relation}
# File lib/hive/models/account.rb, line 126 def ignored_feed_cache; Post.feed_cache(muting); end
All comments that have replied to this account, as in, all content that has the parent_author as this account.
# File lib/hive/models/account.rb, line 136 def replies; Post.replies(parent_author: self); end