aboutsummaryrefslogtreecommitdiff
path: root/web/controllers
diff options
context:
space:
mode:
authorneodarz <neodarz@neodarz.net>2017-02-09 16:29:55 +0100
committerneodarz <neodarz@neodarz.net>2017-02-09 16:29:55 +0100
commite179acd7012cfb021a287f85086978d2942323e9 (patch)
tree654207bb1bd48d292591664a662d04815b4f0e72 /web/controllers
parentb6ee08c2fb5ba808fe152af973b529840097113e (diff)
downloadthe_transcriber_backend-e179acd7012cfb021a287f85086978d2942323e9.tar.xz
the_transcriber_backend-e179acd7012cfb021a287f85086978d2942323e9.zip
Fix a little bug to set the correct id when the file it's uploaded with the api
Diffstat (limited to '')
-rw-r--r--web/controllers/audio_file_api_controller.ex4
1 files changed, 3 insertions, 1 deletions
diff --git a/web/controllers/audio_file_api_controller.ex b/web/controllers/audio_file_api_controller.ex
index 5e97c9c..3dc278e 100644
--- a/web/controllers/audio_file_api_controller.ex
+++ b/web/controllers/audio_file_api_controller.ex
@@ -11,7 +11,9 @@ defmodule TheTranscriberBackend.AudioFileAPIController do
def create(conn, %{"audio_file" => %{"audio_duration" => audio_duration, "audio_path" => upload, "audio_name" => audio_name}}) do
- repo_last_id = (Repo.one(from x in AudioFileAPI, order_by: [desc: x.id], limit: 1)).id
+ query = "select nextval('audio_file_id_seq')"
+ result = Ecto.Adapters.SQL.query!(Repo, query, [])
+ [[repo_last_id]] = result.rows # A beautiful pattern match :)
path = "/media/phoenix_test/#{repo_last_id}_#{upload.filename}"
File.cp(upload.path, path)