feat: upsert stats counters, daily buckets and ETS tops for admin metrics. Refs EventHub/EventHubBack#42 #43 #44 #45 #46
CI / test (push) Failing after 25m40s
CI / deploy-ift (push) Has been skipped
CI / e2e-ift (push) Has been skipped
CI / deploy-stage (push) Has been skipped
CI / e2e-stage (push) Has been skipped

This commit is contained in:
2026-07-17 23:10:00 +03:00
parent f2445db66c
commit dd754e28cc
20 changed files with 1885 additions and 408 deletions
+23 -2
View File
@@ -72,8 +72,27 @@ stop_mnesia() ->
ensure_tables(Tables) when is_list(Tables) ->
lists:foreach(fun ensure_table/1, Tables),
maybe_add_admin_stats_indexes(Tables),
ok.
maybe_add_admin_stats_indexes(Tables) ->
case lists:member(report, Tables) of
true -> add_index(report, resolved_by);
false -> ok
end,
case lists:member(ticket, Tables) of
true -> add_index(ticket, assigned_to);
false -> ok
end.
add_index(Table, Attr) ->
case catch mnesia:add_table_index(Table, Attr) of
{atomic, ok} -> ok;
{aborted, {already_exists, _}} -> ok;
{aborted, {already_exists, _, _}} -> ok;
_ -> ok
end.
ensure_table(Table) ->
case lists:member(Table, mnesia:system_info(tables)) of
true ->
@@ -133,8 +152,10 @@ table_opts(admin_audit) ->
[{ram_copies, [node()]}, {attributes, record_info(fields, admin_audit)}];
table_opts(notification) ->
[{ram_copies, [node()]}, {attributes, record_info(fields, notification)}];
table_opts(stats) ->
[{ram_copies, [node()]}, {attributes, record_info(fields, stats)}];
table_opts(stats_counter) ->
[{ram_copies, [node()]}, {attributes, record_info(fields, stats_counter)}];
table_opts(stats_daily) ->
[{ram_copies, [node()]}, {attributes, record_info(fields, stats_daily)}];
table_opts(session) ->
[{ram_copies, [node()]}, {attributes, record_info(fields, session)}];
table_opts(verification) ->