Skip to content

Commit

Permalink
EiaBulk accept filter argument
Browse files Browse the repository at this point in the history
  • Loading branch information
intermittentnrg committed Dec 24, 2024
1 parent df09e77 commit d2bb428
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
9 changes: 5 additions & 4 deletions lib/eia_bulk.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def self.source_id
end

def self.cli(args)
unless args.length == 1
if args.length < 1
$stderr.puts "#{$0}: <file>"
return
end
Expand Down Expand Up @@ -43,6 +43,7 @@ def process
m = line.match(/"series_id":"(.*?)"/)
next unless m
@series = m[1]
next unless @series.include?(@filter) if @filter
process_line(line) { |row| conn.put_copy_data(row) }
end
end
Expand Down Expand Up @@ -79,7 +80,7 @@ class Generation < Base
BULK_TABLE = "eia_bulk_generation"
TARGET_MODEL = ::Generation

def initialize(args)
def initialize(*args)
super
ActiveRecord::Base.connection.create_enum :eia_bulk_production_type, %w[fossil_gas fossil_hard_coal fossil_oil hydro nuclear other solar wind unknown]
ActiveRecord::Base.connection.create_table BULK_TABLE, id: false, temporary: true do |t|
Expand Down Expand Up @@ -147,7 +148,7 @@ class Demand < Base
BULK_TABLE = "eia_bulk_demand"
TARGET_MODEL = Load

def initialize(args)
def initialize(*args)
super
ActiveRecord::Base.connection.create_table BULK_TABLE, id: false, temporary: true do |t|
t.timestamptz :time, null: false
Expand Down Expand Up @@ -200,7 +201,7 @@ class Interchange < Base
BULK_TABLE = "eia_bulk_interchange"
TARGET_MODEL = Transmission

def initialize(args)
def initialize(*args)
super
ActiveRecord::Base.connection.create_table BULK_TABLE, id: false, temporary: true do |t|
t.timestamptz :time, null: false
Expand Down
6 changes: 0 additions & 6 deletions scripts/stream-eia-eba.rb

This file was deleted.

0 comments on commit d2bb428

Please sign in to comment.