Рефакторинг обработчиков. Часть 3 #21

This commit is contained in:
2026-05-13 23:02:59 +03:00
parent 61bb44ab4a
commit 40806df62a
91 changed files with 6138 additions and 7150 deletions
@@ -87,15 +87,21 @@ parse_subscription_filters(Req) ->
}.
apply_filters(Subs, Filters) ->
Plan = maps:get(plan, Filters, undefined),
Status = maps:get(status, Filters, undefined),
F1 = case Plan of
PlanBin = maps:get(plan, Filters, undefined),
StatusBin = maps:get(status, Filters, undefined),
F1 = case PlanBin of
undefined -> Subs;
_ -> [S || S <- Subs, S#subscription.plan =:= Plan]
_ ->
Plan = try binary_to_existing_atom(PlanBin, utf8)
catch error:badarg -> PlanBin end,
[S || S <- Subs, S#subscription.plan =:= Plan]
end,
case Status of
case StatusBin of
undefined -> F1;
_ -> [S || S <- F1, S#subscription.status =:= Status]
_ ->
Status = try binary_to_existing_atom(StatusBin, utf8)
catch error:badarg -> StatusBin end,
[S || S <- F1, S#subscription.status =:= Status]
end.
sort_subscriptions(Subs, #{sort := Sort, order := Order}) ->