PG_DB.exec("UPDATE users SET watched = watched || $1 WHERE email = $2",[id],user.as(User).email)
PG_DB.exec("UPDATE users SET watched = array_append(watched, $1) WHERE email = $2",id,user.as(User).email)
end
end
ifnotifications&¬ifications.includes?id
ifnotifications&¬ifications.includes?id
@ -748,7 +748,7 @@ get "/embed/:id" do |env|
end
end
# if watched && !watched.includes? id
# if watched && !watched.includes? id
# PG_DB.exec("UPDATE users SET watched = watched || $1 WHERE email = $2", [id], user.as(User).email)
# PG_DB.exec("UPDATE users SET watched = array_append(watched, $1) WHERE email = $2", id, user.as(User).email)
# end
# end
ifnotifications&¬ifications.includes?id
ifnotifications&¬ifications.includes?id
@ -1243,11 +1243,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 = video_count + 1, 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), 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 = video_count - 1, 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), 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
end
end
@ -2244,7 +2244,7 @@ post "/watch_ajax" do |env|
caseaction
caseaction
when"action_mark_watched"
when"action_mark_watched"
if!user.watched.includes?id
if!user.watched.includes?id
PG_DB.exec("UPDATE users SET watched = watched || $1 WHERE email = $2",[id],user.email)
PG_DB.exec("UPDATE users SET watched = array_append(watched, $1) WHERE email = $2",id,user.email)
end
end
when"action_mark_unwatched"
when"action_mark_unwatched"
PG_DB.exec("UPDATE users SET watched = array_remove(watched, $1) WHERE email = $2",id,user.email)
PG_DB.exec("UPDATE users SET watched = array_remove(watched, $1) WHERE email = $2",id,user.email)
@ -3402,7 +3402,7 @@ post "/feed/webhook/:token" do |env|
views:video.views,
views:video.views,
)
)
emails=PG_DB.query_all("UPDATE users SET notifications = notifications || $1\
emails=PG_DB.query_all("UPDATE users SET notifications = array_append(notifications, $1)\