Skip to content

Commit

Permalink
Refactor to matching on filter list structure
Browse files Browse the repository at this point in the history
  • Loading branch information
apata committed Feb 25, 2025
1 parent aa6b89a commit d32d92e
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions lib/plausible/segments/segment.ex
Original file line number Diff line number Diff line change
Expand Up @@ -197,15 +197,10 @@ defmodule Plausible.Segments.Segment do
end

defp dashboard_compatible_filter?(filter) do
regular_filter? =
is_list(filter) and length(filter) == 3 and
is_atom(Enum.at(filter, 0)) and
is_binary(Enum.at(filter, 1)) and
is_list(Enum.at(filter, 2))

has_not_done_filter? =
is_list(filter) and length(filter) == 2 and Enum.at(filter, 0) == :has_not_done

regular_filter? or has_not_done_filter?
case filter do
[operation, dimension, _clauses] when is_atom(operation) and is_binary(dimension) -> true
[:has_not_done, _] -> true
_ -> false
end
end
end

0 comments on commit d32d92e

Please sign in to comment.