Статистика для дашборда #7
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
-export([create/4, get_by_id/1, list_by_target/2, list_by_reporter/1, list_all/0]).
|
||||
-export([update_status/3, get_count_by_target/2]).
|
||||
-export([generate_id/0]).
|
||||
-export([count_reports_by_status/1, count_reports_by_admin/2]).
|
||||
|
||||
%% Создание жалобы
|
||||
create(ReporterId, TargetType, TargetId, Reason) ->
|
||||
@@ -83,6 +84,14 @@ get_count_by_target(TargetType, TargetId) ->
|
||||
Reports = mnesia:dirty_match_object(Match),
|
||||
length(Reports).
|
||||
|
||||
count_reports_by_status(Status) ->
|
||||
Match = #report{status = Status, _ = '_'},
|
||||
length(mnesia:dirty_match_object(Match)).
|
||||
|
||||
count_reports_by_admin(AdminId, Status) ->
|
||||
Match = #report{resolved_by = AdminId, status = Status, _ = '_'},
|
||||
length(mnesia:dirty_match_object(Match)).
|
||||
|
||||
%% Внутренние функции
|
||||
generate_id() ->
|
||||
base64:encode(crypto:strong_rand_bytes(16), #{mode => urlsafe, padding => false}).
|
||||
Reference in New Issue
Block a user