Рефакторинг админских обработчиков - пагинация, сортировка, фильтрация. Финал

This commit is contained in:
2026-05-26 21:50:12 +03:00
parent ed5b275efb
commit 19b3d0dba0
21 changed files with 1833 additions and 421 deletions
+3 -6
View File
@@ -123,14 +123,11 @@ parse_int_qs(Bin, Default) ->
-spec pagination_headers(map(), non_neg_integer()) -> map().
pagination_headers(#{limit := Limit, offset := Offset}, Total) ->
NextOffset = Offset + Limit,
HasMore = NextOffset < Total,
RangeEnd = min(Offset + Limit - 1, Total - 1),
#{
<<"content-range">> => iolist_to_binary(io_lib:format("items ~B-~B/~B", [Offset, RangeEnd, Total])),
<<"x-total-count">> => integer_to_binary(Total),
<<"x-next-offset">> => case HasMore of
true -> integer_to_binary(NextOffset);
false -> <<"">>
end
<<"access-control-expose-headers">> => <<"Content-Range, X-Total-Count">>
}.
%% @doc Преобразует бинарный ISO8601 параметр в datetime().