MSP-1756 remove last session field in user entity and repo
This commit is contained in:
1 parent
92021b8a0e
commit
669542b546
2 files changed
+19
-22
No files matched your search
+14
-16
@@ -3,17 +3,16 @@ package entity
|
||||
import "time"
|
||||
|
||||
type User struct {
|
||||
SudirUserId *string
|
||||
Id int64
|
||||
FirstName string
|
||||
LastName string
|
||||
Description string
|
||||
Email string
|
||||
Password string
|
||||
Blocked bool
|
||||
LastSessionCreatedAt *time.Time
|
||||
UpdatedAt time.Time
|
||||
CreatedAt time.Time
|
||||
SudirUserId *string
|
||||
Id int64
|
||||
FirstName string
|
||||
LastName string
|
||||
Description string
|
||||
Email string
|
||||
Password string
|
||||
Blocked bool
|
||||
UpdatedAt time.Time
|
||||
CreatedAt time.Time
|
||||
}
|
||||
|
||||
type SudirUser struct {
|
||||
@@ -26,9 +25,8 @@ type SudirUser struct {
|
||||
}
|
||||
|
||||
type UpdateUser struct {
|
||||
FirstName string
|
||||
LastName string
|
||||
Email string
|
||||
Description string
|
||||
LastSessionCreatedAt *time.Time
|
||||
FirstName string
|
||||
LastName string
|
||||
Email string
|
||||
Description string
|
||||
}
|
||||
+5
-6
@@ -75,14 +75,13 @@ func (u User) UpsertBySudirUserId(ctx context.Context, user entity.User) (*entit
|
||||
sql_metrics.OperationLabelToContext(ctx, "User.UpsertBySudirUserId")
|
||||
|
||||
selectQ := `
|
||||
insert into users as u (first_name, last_name, email, created_at, updated_at, sudir_user_id, last_session_created_at)
|
||||
values ($1, $2, $3, $4, $5, $6, $7)
|
||||
insert into users as u (first_name, last_name, email, created_at, updated_at, sudir_user_id)
|
||||
values ($1, $2, $3, $4, $5, $6)
|
||||
on conflict (sudir_user_id) do update
|
||||
set first_name = excluded.first_name,
|
||||
last_name = excluded.last_name,
|
||||
email = excluded.email,
|
||||
updated_at = excluded.updated_at,
|
||||
last_session_created_at = excluded.last_session_created_at
|
||||
updated_at = excluded.updated_at
|
||||
where u.blocked = false
|
||||
returning *
|
||||
`
|
||||
@@ -90,7 +89,7 @@ func (u User) UpsertBySudirUserId(ctx context.Context, user entity.User) (*entit
|
||||
err := u.db.SelectRow(ctx,
|
||||
&result,
|
||||
selectQ,
|
||||
user.FirstName, user.LastName, user.Email, user.CreatedAt, user.UpdatedAt, user.SudirUserId, user.LastSessionCreatedAt,
|
||||
user.FirstName, user.LastName, user.Email, user.CreatedAt, user.UpdatedAt, user.SudirUserId,
|
||||
)
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
return nil, domain.ErrNotFound
|
||||
@@ -170,7 +169,7 @@ func (u User) UpdateUser(ctx context.Context, id int64, user entity.UpdateUser)
|
||||
"description": user.Description,
|
||||
}).
|
||||
Where(squirrel.Eq{"id": id}).
|
||||
Suffix("RETURNING id, first_name, last_name, email, sudir_user_id, description, created_at, updated_at, last_session_created_at").
|
||||
Suffix("RETURNING id, first_name, last_name, email, sudir_user_id, description, created_at, updated_at").
|
||||
ToSql()
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "build query")
|
||||
|
||||
Reference in new issue
Block a user