@ -941,11 +941,11 @@ post "/playlist_ajax" do |env|
args=arg_array(video_array)
args=arg_array(video_array)
PG_DB.exec("INSERT INTO playlist_videos VALUES (#{args})",args:video_array)
PG_DB.exec("INSERT INTO playlist_videos VALUES (#{args})",args:video_array)
PG_DB.exec("UPDATE playlists SET index = array_append(index, $1), video_count = cardinality(index), updated = $2 WHERE id = $3",playlist_video.index,Time.utc,playlist_id)
PG_DB.exec("UPDATE playlists SET index = array_append(index, $1), video_count = cardinality(index) + 1, updated = $2 WHERE id = $3",playlist_video.index,Time.utc,playlist_id)
when"action_remove_video"
when"action_remove_video"
index=env.params.query["set_video_id"]
index=env.params.query["set_video_id"]
PG_DB.exec("DELETE FROM playlist_videos * WHERE index = $1",index)
PG_DB.exec("DELETE FROM playlist_videos * WHERE index = $1",index)
PG_DB.exec("UPDATE playlists SET index = array_remove(index, $1), video_count = cardinality(index), updated = $2 WHERE id = $3",index,Time.utc,playlist_id)
PG_DB.exec("UPDATE playlists SET index = array_remove(index, $1), video_count = cardinality(index) - 1, updated = $2 WHERE id = $3",index,Time.utc,playlist_id)
when"action_move_video_before"
when"action_move_video_before"
# TODO: Playlist stub
# TODO: Playlist stub
else
else
@ -2313,7 +2313,7 @@ post "/data_control" do |env|
args=arg_array(video_array)
args=arg_array(video_array)
PG_DB.exec("INSERT INTO playlist_videos VALUES (#{args})",args:video_array)
PG_DB.exec("INSERT INTO playlist_videos VALUES (#{args})",args:video_array)
PG_DB.exec("UPDATE playlists SET index = array_append(index, $1), video_count = cardinality(index), updated = $2 WHERE id = $3",playlist_video.index,Time.utc,playlist.id)
PG_DB.exec("UPDATE playlists SET index = array_append(index, $1), video_count = cardinality(index) + 1, updated = $2 WHERE id = $3",playlist_video.index,Time.utc,playlist.id)
end
end
end
end
end
end
@ -4654,7 +4654,7 @@ post "/api/v1/auth/playlists/:plid/videos" do |env|
args=arg_array(video_array)
args=arg_array(video_array)
PG_DB.exec("INSERT INTO playlist_videos VALUES (#{args})",args:video_array)
PG_DB.exec("INSERT INTO playlist_videos VALUES (#{args})",args:video_array)
PG_DB.exec("UPDATE playlists SET index = array_append(index, $1), video_count = video_count + 1, updated = $2 WHERE id = $3",playlist_video.index,Time.utc,plid)
PG_DB.exec("UPDATE playlists SET index = array_append(index, $1), video_count = cardinality(index) + 1, updated = $2 WHERE id = $3",playlist_video.index,Time.utc,plid)
@ -4688,7 +4688,7 @@ delete "/api/v1/auth/playlists/:plid/videos/:index" do |env|
end
end
PG_DB.exec("DELETE FROM playlist_videos * WHERE index = $1",index)
PG_DB.exec("DELETE FROM playlist_videos * WHERE index = $1",index)
PG_DB.exec("UPDATE playlists SET index = array_remove(index, $1), video_count = video_count - 1, updated = $2 WHERE id = $3",index,Time.utc,plid)
PG_DB.exec("UPDATE playlists SET index = array_remove(index, $1), video_count = cardinality(index) - 1, updated = $2 WHERE id = $3",index,Time.utc,plid)