···11+# This file is auto-generated from the current state of the database. Instead
22+# of editing this file, please use the migrations feature of Active Record to
33+# incrementally modify your database, and then regenerate this schema definition.
44+#
55+# This file is the source Rails uses to define your schema when running `bin/rails
66+# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
77+# be faster and is potentially less error prone than running all of your
88+# migrations from scratch. Old migrations may fail to apply correctly if those
99+# migrations use external dependencies or application code.
1010+#
1111+# It's strongly recommended that you check this file into your version control system.
1212+1313+ActiveRecord::Schema.define(version: 2023_06_15_155215) do
1414+1515+ create_table "feed_posts", force: :cascade do |t|
1616+ t.integer "feed_id", null: false
1717+ t.integer "post_id", null: false
1818+ t.datetime "time", null: false
1919+ t.index ["feed_id", "time"], name: "index_feed_posts_on_feed_id_and_time"
2020+ end
2121+2222+ create_table "posts", force: :cascade do |t|
2323+ t.string "repo", null: false
2424+ t.datetime "time", null: false
2525+ t.string "text", null: false
2626+ t.text "data", null: false
2727+ t.string "rkey", null: false
2828+ t.index ["rkey"], name: "index_posts_on_rkey"
2929+ end
3030+3131+end
+63
firehose.rb
···11+#!/usr/bin/env ruby
22+33+require 'bundler/setup'
44+require_relative 'app/firehose_stream'
55+66+ActiveRecord::Base.logger = nil
77+88+def print_help
99+ puts "Usage: #{$0} [options...]"
1010+ puts "Options:"
1111+ puts
1212+ puts " * Showing progress: [default: show in development]"
1313+ puts " -p = show progress dots for each received message"
1414+ puts " -np = don't show progress dots"
1515+ puts
1616+ puts " * Logging status changes: [default: log in any mode]"
1717+ puts " -ns = don't log status changes"
1818+ puts
1919+ puts " * Logging post text: [default: -lm in development, -nl in production]"
2020+ puts " -lm = log text of matching posts"
2121+ puts " -la = log text of every post"
2222+ puts " -nl = don't log posts"
2323+ puts
2424+ puts " * Saving posts to db: [default: -da in development, -dm in production]"
2525+ puts " -da = save all posts to database"
2626+ puts " -dm = save only matching posts to database"
2727+ puts " -nd = don't save any posts"
2828+end
2929+3030+firehose = FirehoseStream.new
3131+3232+ARGV.each do |arg|
3333+ case arg
3434+ when '-p'
3535+ firehose.show_progress = true
3636+ when '-np'
3737+ firehose.show_progress = false
3838+ when '-ns'
3939+ firehose.log_status = false
4040+ when '-lm'
4141+ firehose.log_posts = :matching
4242+ when '-la'
4343+ firehose.log_posts = :all
4444+ when '-nl'
4545+ firehose.log_posts = false
4646+ when '-dm'
4747+ firehose.save_posts = :matching
4848+ when '-da'
4949+ firehose.save_posts = :all
5050+ when '-nd'
5151+ firehose.save_posts = false
5252+ when '-h', '--help'
5353+ print_help
5454+ exit 0
5555+ else
5656+ puts "Unrecognized option: #{arg}"
5757+ print_help
5858+ exit 1
5959+ end
6060+end
6161+6262+firehose.start
6363+sleep