feat: add custom boolean field state & URL-Parameter
This commit is contained in:
parent
dbec2d020f
commit
37e1553a02
4 changed files with 264 additions and 40 deletions
|
|
@ -19,6 +19,12 @@ defmodule Mv.Constants do
|
|||
|
||||
@custom_field_prefix "custom_field_"
|
||||
|
||||
@boolean_filter_prefix "bf_"
|
||||
|
||||
@max_boolean_filters 50
|
||||
|
||||
@max_uuid_length 36
|
||||
|
||||
@email_validator_checks [:html_input, :pow]
|
||||
|
||||
def member_fields, do: @member_fields
|
||||
|
|
@ -33,6 +39,42 @@ defmodule Mv.Constants do
|
|||
"""
|
||||
def custom_field_prefix, do: @custom_field_prefix
|
||||
|
||||
@doc """
|
||||
Returns the prefix used for boolean custom field filter URL parameters.
|
||||
|
||||
## Examples
|
||||
|
||||
iex> Mv.Constants.boolean_filter_prefix()
|
||||
"bf_"
|
||||
"""
|
||||
def boolean_filter_prefix, do: @boolean_filter_prefix
|
||||
|
||||
@doc """
|
||||
Returns the maximum number of boolean custom field filters allowed per request.
|
||||
|
||||
This limit prevents DoS attacks by restricting the number of filter parameters
|
||||
that can be processed in a single request.
|
||||
|
||||
## Examples
|
||||
|
||||
iex> Mv.Constants.max_boolean_filters()
|
||||
50
|
||||
"""
|
||||
def max_boolean_filters, do: @max_boolean_filters
|
||||
|
||||
@doc """
|
||||
Returns the maximum length of a UUID string (36 characters including hyphens).
|
||||
|
||||
UUIDs in standard format (e.g., "550e8400-e29b-41d4-a716-446655440000") are
|
||||
exactly 36 characters long. This constant is used for input validation.
|
||||
|
||||
## Examples
|
||||
|
||||
iex> Mv.Constants.max_uuid_length()
|
||||
36
|
||||
"""
|
||||
def max_uuid_length, do: @max_uuid_length
|
||||
|
||||
@doc """
|
||||
Returns the email validator checks used for EctoCommons.EmailValidator.
|
||||
|
||||
|
|
|
|||
|
|
@ -303,7 +303,9 @@ defmodule Mv.Membership.Import.MemberCSV do
|
|||
|
||||
{inserted, failed, errors, _collected_error_count, truncated?} =
|
||||
Enum.reduce(chunk_rows_with_lines, {0, 0, [], 0, false}, fn {line_number, row_map},
|
||||
{acc_inserted, acc_failed, acc_errors, acc_error_count, acc_truncated?} ->
|
||||
{acc_inserted, acc_failed,
|
||||
acc_errors, acc_error_count,
|
||||
acc_truncated?} ->
|
||||
current_error_count = existing_error_count + acc_error_count
|
||||
|
||||
case process_row(row_map, line_number, custom_field_lookup) do
|
||||
|
|
@ -325,7 +327,13 @@ defmodule Mv.Membership.Import.MemberCSV do
|
|||
end
|
||||
end)
|
||||
|
||||
{:ok, %{inserted: inserted, failed: failed, errors: Enum.reverse(errors), errors_truncated?: truncated?}}
|
||||
{:ok,
|
||||
%{
|
||||
inserted: inserted,
|
||||
failed: failed,
|
||||
errors: Enum.reverse(errors),
|
||||
errors_truncated?: truncated?
|
||||
}}
|
||||
end
|
||||
|
||||
@doc """
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue