How to List Accounts Sorted by Newest Blog EntrysteemCreated with Sketch.

in #radiator8 years ago

Sometimes, it's nice to find out who posted lately, all in one result. If you have a list of account names you'd like to review, this script will sort them from newest to oldest blog entry.

As always, we use Radiator with bundler. You can get bundler with this command:

$ gem install bundler

I've tested it on various versions of ruby. The oldest one I got it to work was:

ruby 2.0.0p645 (2015-04-13 revision 50299) [x86_64-darwin14.4.0]

First, make a project folder:

$ mkdir radiator
$ cd radiator

Create a file named Gemfile containing:

source 'https://rubygems.org'
gem 'radiator', github: 'inertia186/radiator'

Then run the command:

$ bundle install

Create a file named accounts_by_last_root_post.rb containing:

require 'rubygems'
require 'bundler/setup'

Bundler.require

puts "Usage: ruby #{__FILE__} <accounts>" and return if ARGV.empty?

api = Radiator::Api.new
names = ARGV

response = api.get_accounts(names)
accounts = response.result

accounts = accounts.sort_by do |account|
  account.last_root_post
end.reverse

accounts.each do |account|
  puts "https://steemit.com/@#{account.name}, last root post: #{account.last_root_post}"
end

Then run it:

$ ruby accounts_by_last_root_post.rb abit alexgr anyx bitcoiner cheftony fubar-bdhr instructor2121 klye konti liberosist lovejoy patrice pharesim picokernel royaltiffany samupaha steemychicken1

You can also use the output of another script, like the one mentioned earlier:

$ ruby accounts_by_last_root_post.rb `ruby all_followers.rb ned`

The expected output will be something like this:

https://steemit.com/@jrcornel, last root post: 2016-10-02T15:31:39
https://steemit.com/@intan, last root post: 2016-10-02T15:29:42
https://steemit.com/@serejandmyself, last root post: 2016-10-02T15:28:51
https://steemit.com/@chadcrypto, last root post: 2016-10-02T15:26:15
https://steemit.com/@jlufer, last root post: 2016-10-02T15:16:45
https://steemit.com/@acidsun, last root post: 2016-10-02T15:14:57
https://steemit.com/@steevc, last root post: 2016-10-02T15:12:09
https://steemit.com/@norbu, last root post: 2016-10-02T15:10:21
https://steemit.com/@ericvancewalton, last root post: 2016-10-02T15:08:18
https://steemit.com/@naturalista, last root post: 2016-10-02T15:05:42
.
.
.

ruby

See my previous Ruby How To posts in: #radiator #ruby

Sort:  

thank you. I was wondering how to get this overview of latest posts and accounts.

Woo! I'm mentioned in your argv! =D

Yep. Those are the witnesses who follow me. ;)

Ah I see! Go me!