mirror of
https://github.com/plausible/analytics.git
synced 2024-12-23 09:33:19 +03:00
Use one typespec for two clauses
This commit is contained in:
parent
00b68779ed
commit
8d8cd21764
@ -6,7 +6,8 @@ defmodule Plausible.Stats.Sampling do
|
||||
|
||||
import Ecto.Query
|
||||
|
||||
@spec add_query_hint(Ecto.Query.t(), Plausible.Stats.Query.t()) :: Ecto.Query.t()
|
||||
@spec add_query_hint(Ecto.Query.t(), Plausible.Stats.Query.t() | pos_integer()) ::
|
||||
Ecto.Query.t()
|
||||
def add_query_hint(%Ecto.Query{} = db_query, %Plausible.Stats.Query{} = query) do
|
||||
case query.sample_threshold do
|
||||
:infinite ->
|
||||
@ -17,7 +18,6 @@ defmodule Plausible.Stats.Sampling do
|
||||
end
|
||||
end
|
||||
|
||||
@spec add_query_hint(Ecto.Query.t(), pos_integer()) :: Ecto.Query.t()
|
||||
def add_query_hint(%Ecto.Query{} = query, threshold) when is_integer(threshold) do
|
||||
from(x in query, hints: [sample: threshold])
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user