From 118877f7270d51759b9e78d29b818f6d5eb9c3f7 Mon Sep 17 00:00:00 2001 From: LandaMm Date: Wed, 4 Jun 2025 20:07:48 +0200 Subject: [PATCH] feat: user update last login --- internal/repository/users.sql.go | 11 +++++++++++ queries/users.sql | 5 +++++ 2 files changed, 16 insertions(+) diff --git a/internal/repository/users.sql.go b/internal/repository/users.sql.go index 5de83ad..39b2c1e 100644 --- a/internal/repository/users.sql.go +++ b/internal/repository/users.sql.go @@ -118,6 +118,17 @@ func (q *Queries) InsertUser(ctx context.Context, arg InsertUserParams) (uuid.UU return id, err } +const updateLastLogin = `-- name: UpdateLastLogin :exec +UPDATE users +SET last_login = NOW() +WHERE id = $1 +` + +func (q *Queries) UpdateLastLogin(ctx context.Context, id uuid.UUID) error { + _, err := q.db.Exec(ctx, updateLastLogin, id) + return err +} + const updateProfilePicture = `-- name: UpdateProfilePicture :exec UPDATE users SET profile_picture = $1 diff --git a/queries/users.sql b/queries/users.sql index d7e7f06..92ecb35 100644 --- a/queries/users.sql +++ b/queries/users.sql @@ -19,3 +19,8 @@ SELECT * FROM users WHERE id = $1 LIMIT 1; UPDATE users SET profile_picture = $1 WHERE id = $2; + +-- name: UpdateLastLogin :exec +UPDATE users +SET last_login = NOW() +WHERE id = $1;