7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/podrb/commands/delete/runner.rb', line 7
def call(podcast_id)
db = Infrastructure::Storage::SQL.new(db: podrb_db_dir)
if db.query("select id from podcasts where id = #{podcast_id}").empty?
return build_failure_response(details: :not_found)
end
sql_code = <<~SQL
delete from episodes
where podcast_id = #{podcast_id};
SQL
db.execute(sql_code)
sql_code = <<~SQL
delete from podcasts
where id = #{podcast_id};
SQL
db.execute(sql_code)
build_success_response(details: :podcast_deleted)
end
|