mirror of
https://github.com/iv-org/invidious.git
synced 2024-11-23 05:57:21 +00:00
db: use now() function instead of passing Time.utc
This commit is contained in:
parent
714a001332
commit
ce4a52325b
@ -35,31 +35,31 @@ module Invidious::Database::Channels
|
|||||||
def update_author(id : String, author : String)
|
def update_author(id : String, author : String)
|
||||||
request = <<-SQL
|
request = <<-SQL
|
||||||
UPDATE channels
|
UPDATE channels
|
||||||
SET updated = $1, author = $2, deleted = false
|
SET updated = now(), author = $1, deleted = false
|
||||||
WHERE id = $3
|
WHERE id = $2
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
PG_DB.exec(request, Time.utc, author, id)
|
PG_DB.exec(request, author, id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_subscription_time(id : String)
|
def update_subscription_time(id : String)
|
||||||
request = <<-SQL
|
request = <<-SQL
|
||||||
UPDATE channels
|
UPDATE channels
|
||||||
SET subscribed = $1
|
SET subscribed = now()
|
||||||
WHERE id = $2
|
WHERE id = $1
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
PG_DB.exec(request, Time.utc, id)
|
PG_DB.exec(request, id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_mark_deleted(id : String)
|
def update_mark_deleted(id : String)
|
||||||
request = <<-SQL
|
request = <<-SQL
|
||||||
UPDATE channels
|
UPDATE channels
|
||||||
SET updated = $1, deleted = true
|
SET updated = now(), deleted = true
|
||||||
WHERE id = $2
|
WHERE id = $1
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
PG_DB.exec(request, Time.utc, id)
|
PG_DB.exec(request, id)
|
||||||
end
|
end
|
||||||
|
|
||||||
# -------------------
|
# -------------------
|
||||||
|
@ -59,11 +59,11 @@ module Invidious::Database::Playlists
|
|||||||
def update_subscription_time(id : String)
|
def update_subscription_time(id : String)
|
||||||
request = <<-SQL
|
request = <<-SQL
|
||||||
UPDATE playlists
|
UPDATE playlists
|
||||||
SET subscribed = $1
|
SET subscribed = now()
|
||||||
WHERE id = $2
|
WHERE id = $1
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
PG_DB.exec(request, Time.utc, id)
|
PG_DB.exec(request, id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_video_added(id : String, index : String | Int64)
|
def update_video_added(id : String, index : String | Int64)
|
||||||
@ -71,11 +71,11 @@ module Invidious::Database::Playlists
|
|||||||
UPDATE playlists
|
UPDATE playlists
|
||||||
SET index = array_append(index, $1),
|
SET index = array_append(index, $1),
|
||||||
video_count = cardinality(index) + 1,
|
video_count = cardinality(index) + 1,
|
||||||
updated = $2
|
updated = now()
|
||||||
WHERE id = $3
|
WHERE id = $2
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
PG_DB.exec(request, index, Time.utc, id)
|
PG_DB.exec(request, index, id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_video_removed(id : String, index : String | Int64)
|
def update_video_removed(id : String, index : String | Int64)
|
||||||
@ -83,11 +83,11 @@ module Invidious::Database::Playlists
|
|||||||
UPDATE playlists
|
UPDATE playlists
|
||||||
SET index = array_remove(index, $1),
|
SET index = array_remove(index, $1),
|
||||||
video_count = cardinality(index) - 1,
|
video_count = cardinality(index) - 1,
|
||||||
updated = $2
|
updated = now()
|
||||||
WHERE id = $3
|
WHERE id = $2
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
PG_DB.exec(request, index, Time.utc, id)
|
PG_DB.exec(request, index, id)
|
||||||
end
|
end
|
||||||
|
|
||||||
# -------------------
|
# -------------------
|
||||||
|
@ -10,12 +10,12 @@ module Invidious::Database::SessionIDs
|
|||||||
def insert(sid : String, email : String, handle_conflicts : Bool = false)
|
def insert(sid : String, email : String, handle_conflicts : Bool = false)
|
||||||
request = <<-SQL
|
request = <<-SQL
|
||||||
INSERT INTO session_ids
|
INSERT INTO session_ids
|
||||||
VALUES ($1, $2, $3)
|
VALUES ($1, $2, now())
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
request += " ON CONFLICT (id) DO NOTHING" if handle_conflicts
|
request += " ON CONFLICT (id) DO NOTHING" if handle_conflicts
|
||||||
|
|
||||||
PG_DB.exec(request, sid, email, Time.utc)
|
PG_DB.exec(request, sid, email)
|
||||||
end
|
end
|
||||||
|
|
||||||
# -------------------
|
# -------------------
|
||||||
|
@ -143,11 +143,11 @@ module Invidious::Database::Users
|
|||||||
def clear_notifications(user : User)
|
def clear_notifications(user : User)
|
||||||
request = <<-SQL
|
request = <<-SQL
|
||||||
UPDATE users
|
UPDATE users
|
||||||
SET notifications = '{}', updated = $1
|
SET notifications = '{}', updated = now()
|
||||||
WHERE email = $2
|
WHERE email = $1
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
PG_DB.exec(request, Time.utc, user.email)
|
PG_DB.exec(request, user.email)
|
||||||
end
|
end
|
||||||
|
|
||||||
# -------------------
|
# -------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user