Update: ActiveRecord SteemSQL Models - SteemSQL Ruby 1.1.6

in HiveSQL9 months ago (edited)

I've added support for the tables that @arcange provided not too long ago. I have also released some example scripts on utilizing these new tables to moderate communities:

https://gist.github.com/inertia186/4b448709022a9744dbfe7fe9c3dd3f99

For example, if you wanted to get a list of all communities matching a certain text pattern:

require 'rubygems'
require 'bundler/setup'

Bundler.require

communities = SteemApi::Community.all.includes(:admin_roles)

communities = communities.query(ARGV.join(' '), include_roles: true) if ARGV.any?

communities.order(TS: :asc).each do |community|
  admin = community.admin_roles.first.account rescue '???'

  puts "https://steemit.com/created/#{community.name}: \"#{community.title}\" by #{admin}"
end

Example result:

bucky:communities_moderation (master *)$ ruby list_communities.rb photography
https://steemit.com/created/hive-147017: "Monochrom" by angel35mm
https://steemit.com/created/hive-100001: "Travel Hacks" by travelfeed
https://steemit.com/created/hive-110570: "Delaware Valley Life" by remlaps
https://steemit.com/created/hive-119845: "Photography" by kommienezuspadt
https://steemit.com/created/hive-125278: "Boudoir photography" by s3rg3
https://steemit.com/created/hive-129823: "Photography" by ivansnz
https://steemit.com/created/hive-133975: "Surfing" by betterthanhome
https://steemit.com/created/hive-147474: "Camping and Hiking" by travelfeed
https://steemit.com/created/hive-149293: "Photography" by cknr7
https://steemit.com/created/hive-154013: "Photography" by thewriting
https://steemit.com/created/hive-127523: "Pinup" by bettynoir
https://steemit.com/created/hive-144444: "Road Trips" by travelfeed
https://steemit.com/created/hive-104387: "Urban Exploration" by slobberchops
https://steemit.com/created/hive-166666: "Backpacking" by travelfeed
https://steemit.com/created/hive-175621: "Photography " by susanli3769
https://steemit.com/created/hive-195541: "Food Photography" by pixaroma
https://steemit.com/created/hive-195725: "honusurf" by honusurf
https://steemit.com/created/hive-199999: "Digital Nomads" by travelfeed
https://steemit.com/created/hive-155555: "Food of the World" by travelfeed
https://steemit.com/created/hive-193083: "Photography" by jwolf
https://steemit.com/created/hive-194913: "Photography Lovers" by derangedvisions
https://steemit.com/created/hive-100705: "Solo travel" by travelfeed
https://steemit.com/created/hive-133306: "Macro" by pixaroma
https://steemit.com/created/hive-187747: "imaging" by imagineering
https://steemit.com/created/hive-135468: "Walkers Making Way" by samic
https://steemit.com/created/hive-106444: "Feathered Friends" by melinda010100
https://steemit.com/created/hive-187635: "Caturday" by saboin
https://steemit.com/created/hive-146701: "PhotoGames" by jarvie
https://steemit.com/created/hive-146088: "Offroading" by jarvie
https://steemit.com/created/hive-131392: "CLICK" by jarvie
https://steemit.com/created/hive-127238: "Picture A Day" by jarvie
https://steemit.com/created/hive-150280: "Agricultural Mindset" by mattsanthonyit
https://steemit.com/created/hive-181964: "PHOTOGRAPHY [DAC]" by steempeak
https://steemit.com/created/hive-191315: "PL-TravelFeed" by pl-travelfeed
https://steemit.com/created/hive-165717: "Photography" by sunnylife
https://steemit.com/created/hive-177428: "Macro Photography" by aiqabrago
https://steemit.com/created/hive-142159: "Black And White" by ewkaw
https://steemit.com/created/hive-177777: "Hitchhiking" by travelfeed
https://steemit.com/created/hive-136361: "ES TravelFeed" by travelfeed
https://steemit.com/created/hive-188888: "CycleFeed" by cyclefeed
https://steemit.com/created/hive-122222: "Flights" by travelfeed
https://steemit.com/created/hive-133337: "Budget Travel" by travelfeed
https://steemit.com/created/hive-165890: "Nature" by sunnylife
https://steemit.com/created/hive-192608: "Sunset" by sunnylife
https://steemit.com/created/hive-145690: "Adelaide Photography" by holoz0r
https://steemit.com/created/hive-175538: "Portrait Photography" by jasonrussell
https://steemit.com/created/hive-164277: "Food & photography" by yousafharoonkhan
https://steemit.com/created/hive-198761: "ORIGINAL TALENT" by acostaeladio
https://steemit.com/created/hive-150047: "ReggaeSteem" by dmilliz
https://steemit.com/created/hive-179260: "Mountain Photography" by unipsycho
https://steemit.com/created/hive-153349: "Photofeed" by photofeed
https://steemit.com/created/hive-184437: "TravelFeed" by travelfeed
https://steemit.com/created/hive-163051: "Black Fox" by foxkoit
https://steemit.com/created/hive-164221: "LandscapePhotography" by revo
https://steemit.com/created/hive-103030: "DE-TravelFeed" by travelfeed
https://steemit.com/created/hive-129292: "KR-TravelFeed" by travelfeed
https://steemit.com/created/hive-171717: "IT-TravelFeed" by travelfeed
https://steemit.com/created/hive-123123: "CN-TravelFeed" by travelfeed
https://steemit.com/created/hive-183855: "Photocircle" by photocircle
https://steemit.com/created/hive-165518: "Wedding Photography" by dexter-k
https://steemit.com/created/hive-164622: "Travel" by dexter-k
https://steemit.com/created/hive-185836: "@hive-185836" by xpilar
https://steemit.com/created/hive-174695: "LMAC" by shaka

See github repo: https://github.com/netuoso/steem_api

It also works well with Rails:

  • Add Gem to Gemfile
    • `gem 'steem_api'
  • Bundle Install Gems
    • bundle install

Please note that SteemSQL is a monthly subscription. If you intend to use SteemSQL through this gem, you must subscribe to @steemsql and store the credentials as environment variables. You can provide the credentials in authorize-steem-sql.sh, then use this terminal command to enable SteemSQL just before running your project.

How to Subscribe

For example, create authorize-steem-sql.sh and add your credentials:

#!/bin/bash

export STEEMSQL_HOST=vip.steemsql.com
export STEEMSQL_USERNAME=
export STEEMSQL_PASSWORD=

Then execute it as:

source authorize-steem-sql.sh
Sort:  
 9 months ago Reveal Comment