db: use now() function instead of passing Time.utc

pull/2845/head
Samantaz Fox 3 years ago
parent 714a001332
commit ce4a52325b
No known key found for this signature in database
GPG Key ID: F42821059186176E

@ -35,31 +35,31 @@ module Invidious::Database::Channels
def update_author(id : String, author : String)
request = <<-SQL
UPDATE channels
SET updated = $1, author = $2, deleted = false
WHERE id = $3
SET updated = now(), author = $1, deleted = false
WHERE id = $2
SQL
PG_DB.exec(request, Time.utc, author, id)
PG_DB.exec(request, author, id)
end
def update_subscription_time(id : String)
request = <<-SQL
UPDATE channels
SET subscribed = $1
WHERE id = $2
SET subscribed = now()
WHERE id = $1
SQL
PG_DB.exec(request, Time.utc, id)
PG_DB.exec(request, id)
end
def update_mark_deleted(id : String)
request = <<-SQL
UPDATE channels
SET updated = $1, deleted = true
WHERE id = $2
SET updated = now(), deleted = true
WHERE id = $1
SQL
PG_DB.exec(request, Time.utc, id)
PG_DB.exec(request, id)
end
# -------------------

@ -59,11 +59,11 @@ module Invidious::Database::Playlists
def update_subscription_time(id : String)
request = <<-SQL
UPDATE playlists
SET subscribed = $1
WHERE id = $2
SET subscribed = now()
WHERE id = $1
SQL
PG_DB.exec(request, Time.utc, id)
PG_DB.exec(request, id)
end
def update_video_added(id : String, index : String | Int64)
@ -71,11 +71,11 @@ module Invidious::Database::Playlists
UPDATE playlists
SET index = array_append(index, $1),
video_count = cardinality(index) + 1,
updated = $2
WHERE id = $3
updated = now()
WHERE id = $2
SQL
PG_DB.exec(request, index, Time.utc, id)
PG_DB.exec(request, index, id)
end
def update_video_removed(id : String, index : String | Int64)
@ -83,11 +83,11 @@ module Invidious::Database::Playlists
UPDATE playlists
SET index = array_remove(index, $1),
video_count = cardinality(index) - 1,
updated = $2
WHERE id = $3
updated = now()
WHERE id = $2
SQL
PG_DB.exec(request, index, Time.utc, id)
PG_DB.exec(request, index, id)
end
# -------------------

@ -10,12 +10,12 @@ module Invidious::Database::SessionIDs
def insert(sid : String, email : String, handle_conflicts : Bool = false)
request = <<-SQL
INSERT INTO session_ids
VALUES ($1, $2, $3)
VALUES ($1, $2, now())
SQL
request += " ON CONFLICT (id) DO NOTHING" if handle_conflicts
PG_DB.exec(request, sid, email, Time.utc)
PG_DB.exec(request, sid, email)
end
# -------------------

@ -143,11 +143,11 @@ module Invidious::Database::Users
def clear_notifications(user : User)
request = <<-SQL
UPDATE users
SET notifications = '{}', updated = $1
WHERE email = $2
SET notifications = '{}', updated = now()
WHERE email = $1
SQL
PG_DB.exec(request, Time.utc, user.email)
PG_DB.exec(request, user.email)
end
# -------------------

Loading…
Cancel
Save