Skip to content

Instantly share code, notes, and snippets.

@stuartambient
Created November 18, 2017 01:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stuartambient/d04fc61c5747918541da1f37beda25f9 to your computer and use it in GitHub Desktop.
Save stuartambient/d04fc61c5747918541da1f37beda25f9 to your computer and use it in GitHub Desktop.
Inserting the album_sub_folder id conditional statement
# is it possible to have an if statement in the insert
# dataset and map works in bin/sequel so that is not the problem
check_ids = DB.fetch("SELECT * FROM album_sub_folders WHERE album_id = {@album_id}")
.....
.....
MUSIC_FILES.insert(file_name: File.basename(entry),
album_id: @album_id,
album_sub_folder_id: @asf_id if check_ids.map.count > 0,
mf_path: File.expand_path(entry),
size: File.new(entry).size,
created_on: File.ctime(entry),
modified_on: File.mtime(entry),
file_extension: File.extname(entry)) if File.file?(File.absolute_path(entry))
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment