Class: Podrb::Commands::Dearchive::Runner

Inherits:
BaseRunner
  • Object
show all
Defined in:
lib/podrb/commands/dearchive/runner.rb

Instance Method Summary collapse

Methods inherited from BaseRunner

call

Instance Method Details

#call(episode_id) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/podrb/commands/dearchive/runner.rb', line 7

def call(episode_id)
  db = Infrastructure::Storage::SQL.new(db: podrb_db_dir)

  if db.query("select id from episodes where id = #{episode_id}").empty?
    return build_failure_response(details: :not_found)
  end

  sql_code = "    update episodes\n    set archived_at = null\n    where id = \#{episode_id};\n  SQL\n  db.execute(sql_code)\n\n  build_success_response(details: :episode_dearchived)\nend\n"