Fix /v1/admin/stats всегда пустые данные

Добавлено поле с датой последнего логина пользователям и админам  #20
This commit is contained in:
2026-05-08 20:21:04 +03:00
parent 1132341b92
commit ecf68ee300
9 changed files with 82 additions and 8 deletions
+10 -1
View File
@@ -1,7 +1,7 @@
-module(core_user).
-include("records.hrl").
-export([create/2, get_by_id/1, get_by_email/1, update/2, update_status/3, delete/1]).
-export([create/2, get_by_id/1, get_by_email/1, update/2, update_status/3, delete/1, update_last_login/1]).
-export([email_exists/1]).
-export([generate_id/0]).
-export([list_users/0]).
@@ -80,6 +80,15 @@ update(Id, Updates) ->
{aborted, Reason} -> {error, Reason}
end.
update_last_login(Id) ->
case get_by_id(Id) of
{ok, User} ->
Updated = User#user{last_login = calendar:universal_time()},
mnesia:dirty_write(Updated),
{ok, Updated};
Error -> Error
end.
update_status(Id, Status, Reason) ->
case get_by_id(Id) of
{ok, User} ->