Skip to content

Commit

Permalink
fix: disable User.lastAccessAt field for now.
Browse files Browse the repository at this point in the history
Updating it on every request was cause DB retentions/lock errors
  • Loading branch information
deluan committed Jan 28, 2020
1 parent d4edff3 commit 3007ca6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
14 changes: 7 additions & 7 deletions engine/users.go
Expand Up @@ -7,7 +7,6 @@ import (
"fmt"
"strings"

"github.com/deluan/navidrome/log"
"github.com/deluan/navidrome/model"
)

Expand Down Expand Up @@ -49,11 +48,12 @@ func (u *users) Authenticate(ctx context.Context, username, pass, token, salt st
if !valid {
return nil, model.ErrInvalidAuth
}
go func() {
err := u.ds.User(ctx).UpdateLastAccessAt(user.ID)
if err != nil {
log.Error(ctx, "Could not update user's lastAccessAt", "user", user.UserName)
}
}()
// TODO: Find a way to update LastAccessAt without causing too much retention in the DB
//go func() {
// err := u.ds.User(ctx).UpdateLastAccessAt(user.ID)
// if err != nil {
// log.Error(ctx, "Could not update user's lastAccessAt", "user", user.UserName)
// }
//}()
return user, nil
}
2 changes: 1 addition & 1 deletion ui/src/user/UserEdit.js
Expand Up @@ -23,7 +23,7 @@ const UserEdit = (props) => (
<PasswordInput source="password" validate={[required()]} />
<BooleanInput source="isAdmin" initialValue={false} />
<DateField source="lastLoginAt" showTime />
<DateField source="lastAccessAt" showTime />
{/*<DateField source="lastAccessAt" showTime />*/}
<DateField source="updatedAt" showTime />
<DateField source="createdAt" showTime />
</SimpleForm>
Expand Down
5 changes: 2 additions & 3 deletions ui/src/user/UserList.js
Expand Up @@ -33,16 +33,15 @@ const UserList = (props) => {
<SimpleList
primaryText={(record) => record.name}
secondaryText={(record) =>
record.lastAccessAt &&
new Date(record.lastAccessAt).toLocaleString()
record.lastLoginAt && new Date(record.lastLoginAt).toLocaleString()
}
tertiaryText={(record) => (record.isAdmin ? '[admin]️' : '')}
/>
) : (
<Datagrid rowClick="edit">
<TextField source="userName" />
<BooleanField source="isAdmin" />
<DateField source="lastAccessAt" locales="pt-BR" />
<DateField source="lastLoginAt" locales="pt-BR" />
<DateField source="updatedAt" locales="pt-BR" />
</Datagrid>
)}
Expand Down

0 comments on commit 3007ca6

Please sign in to comment.