Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions .dialyzer_ignore.exs
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,13 @@
{"lib/logflare/backends/adaptor/bigquery_adaptor.ex", :pattern_match},
{"lib/logflare/backends/adaptor/bigquery_adaptor.ex", :pattern_match_cov},
{"lib/logflare/backends/adaptor/clickhouse_adaptor.ex", :pattern_match},
{"lib/logflare/backends/adaptor/clickhouse_adaptor/provisioner.ex", :pattern_match},
{"lib/logflare/backends/adaptor/clickhouse_adaptor/query_connection_sup.ex", :unknown_type},
{"lib/logflare/backends/adaptor/loki_adaptor.ex", :no_return},
{"lib/logflare/backends/adaptor/loki_adaptor.ex", :call},
{"lib/logflare/billing/stripe.ex", :no_return},
{"lib/logflare/billing/stripe.ex", :call},
{"lib/logflare/endpoints.ex", :no_return},
{"lib/logflare/endpoints.ex", :call},
{"lib/logflare/google/bigquery/bigquery.ex", :no_return},
{"lib/logflare/google/bigquery/bigquery.ex", :call},
{"lib/logflare/google/bigquery/bigquery.ex", :pattern_match},
{"lib/logflare/google/cloud_resource_manager.ex", :call},
{"lib/logflare/google/cloud_resource_manager.ex", :pattern_match},
Expand All @@ -33,9 +30,6 @@
{"lib/logflare/logs/search_query_executor.ex", :no_return},
{"lib/logflare/lql/parser.ex", :no_return},
{"lib/logflare/lql/parser.ex", :unused_fun},
{"lib/logflare/pubsub_rates/cache.ex", :invalid_contract},
{"lib/logflare/pubsub_rates/cache.ex", :no_return},
{"lib/logflare/pubsub_rates/cache.ex", :call},
{"lib/logflare/sources.ex", :no_return},
{"lib/logflare/sources.ex", :call},
{"lib/logflare/sources/source/bigquery/pipeline.ex", :pattern_match},
Expand All @@ -46,11 +40,9 @@
{"lib/logflare/sources/source/slack_hook_server/slack_hook_server.ex", :unused_fun},
{"lib/logflare/sources/source/supervisor.ex", :pattern_match},
{"lib/logflare/sources/source/supervisor.ex", :pattern_match_cov},
{"lib/logflare/sources/source/supervisor.ex", :no_return},
{"lib/logflare/sources/source/webhook_notification_server/webhook_notification_server.ex",
:unused_fun},
{"lib/logflare/sql/dialect_translation.ex", :pattern_match},
{"lib/logflare/sql/dialect_translation.ex", :guard_fail},
{"lib/logflare_web/controllers/api/endpoint_controller.ex", :pattern_match},
{"lib/logflare_web/controllers/billing_controller.ex", :unused_fun},
{"lib/logflare_web/controllers/billing_controller.ex", :pattern_match_cov},
Expand Down
4 changes: 2 additions & 2 deletions lib/logflare/google/bigquery/bigquery.ex
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ defmodule Logflare.Google.BigQuery do

@type ok_err_tup :: {:ok, term} | {:error, term}

@spec init_table!(pos_integer(), atom(), String.t(), integer(), String.t(), String.t()) ::
@spec init_table!(User.id(), atom(), String.t(), integer(), String.t(), String.t()) ::
ok_err_tup
def init_table!(user_id, source, project_id, ttl, dataset_location, dataset_id)
when is_integer(user_id) and is_atom(source) and is_binary(project_id) and is_integer(ttl) and
Expand Down Expand Up @@ -228,7 +228,7 @@ defmodule Logflare.Google.BigQuery do
@doc """
Creates dataset, accepts user_id, dataset_id, dataset_location, project_id
"""
@spec create_dataset(String.t(), String.t(), String.t(), String.t()) ::
@spec create_dataset(User.id(), String.t(), String.t(), String.t()) ::
{:ok, Model.Dataset.t()} | {:error, Tesla.Env.t()}
def create_dataset(
user_id,
Expand Down
4 changes: 2 additions & 2 deletions lib/logflare/pubsub_rates/cache.ex
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ defmodule Logflare.PubSubRates.Cache do
@doc """
Returns a node mapping of buffer lengths across the cluster.
"""
@spec get_buffers(non_neg_integer() | :consolidated, non_neg_integer() | nil) :: map()
@spec get_buffers(non_neg_integer() | :consolidated, non_neg_integer() | nil) :: {atom(), map()}
def get_buffers(source_id, backend_id) do
Cachex.get(__MODULE__, {source_id, backend_id, "buffers"})
end
Expand All @@ -108,7 +108,7 @@ defmodule Logflare.PubSubRates.Cache do
Returns the sum of all buffers across the cluster for a given source and backend combination.
"""
@spec get_cluster_buffers(non_neg_integer()) :: non_neg_integer()
@spec get_cluster_buffers(non_neg_integer(), non_neg_integer()) :: non_neg_integer()
@spec get_cluster_buffers(non_neg_integer(), non_neg_integer() | nil) :: non_neg_integer()
def get_cluster_buffers(source_id, backend_id \\ nil) when is_integer(source_id) do
case get_buffers(source_id, backend_id) do
{:ok, node_buffers} when node_buffers != nil -> merge_buffers(node_buffers)
Expand Down
6 changes: 3 additions & 3 deletions lib/logflare/user.ex
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ defmodule Logflare.User do
alias Logflare.Partners.Partner
alias Logflare.Alerting.AlertQuery

@type id :: pos_integer()

@derive {Jason.Encoder,
only: [
:email,
Expand Down Expand Up @@ -228,8 +230,6 @@ defmodule Logflare.User do

def validate_gcp_project(changeset, field, options \\ []) do
validate_change(changeset, field, fn _, bigquery_project_id ->
user_id = Integer.to_string(options[:user_id])

dataset_id =
changeset.changes[:bigquery_dataset_id] ||
"#{options[:user_id]}" <> GCPConfig.dataset_id_append()
Expand All @@ -239,7 +239,7 @@ defmodule Logflare.User do
project_id = bigquery_project_id || bq_project_id()

case BigQuery.create_dataset(
user_id,
options[:user_id],
dataset_id,
location,
project_id
Expand Down
3 changes: 1 addition & 2 deletions test/logflare_web/controllers/user_controller_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,7 @@ defmodule LogflareWeb.UserControllerTest do
)

TestUtils.retry_assert(fn ->
u_id = to_string(u1_id)
assert_received {{:user_id, :project_id}, {^u_id, ^bq_project_id}}
assert_received {{:user_id, :project_id}, {^u1_id, ^bq_project_id}}
end)

TestUtils.retry_assert(fn ->
Expand Down
Loading