Skip to content

Commit

Permalink
Merge branch 'master' into cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
tspenov authored Jan 21, 2025
2 parents f5793c0 + 26367d8 commit 0ffdea9
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 14 deletions.
11 changes: 2 additions & 9 deletions lib/sanbase/social_data/social_volume.ex
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,8 @@ defmodule Sanbase.SocialData.SocialVolume do
}
|> Jason.encode_to_iodata!()

options = [
recv_timeout: @recv_timeout
]

# metricshub reads data from request.query_string and request.form
# Put this header so the data is read from the body properly
headers = [
{"Content-Type", "application/x-www-form-urlencoded"}
]
options = [recv_timeout: @recv_timeout]
headers = [{"Content-Type", "application/json"}]

http_client().post(url, body, headers, options)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/sanbase_web/graphql/resolvers/user/user_resolver.ex
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ defmodule SanbaseWeb.Graphql.Resolvers.UserResolver do
Sanbase.Queries.Authorization.query_executions_limit(subscription_product, plan_name)

result = %{
credits_availalbe_month: credits_limit,
credits_available_month: credits_limit,
credits_spent_month: details.monthly_credits_spent,
credits_remaining_month: credits_limit - details.monthly_credits_spent,
queries_executed_month: details.queries_executed_month,
Expand Down
2 changes: 1 addition & 1 deletion lib/sanbase_web/graphql/schema/types/user_types.ex
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ defmodule SanbaseWeb.Graphql.UserTypes do
end

object :queries_executions_info do
field(:credits_availalbe_month, non_null(:integer))
field(:credits_available_month, non_null(:integer))
field(:credits_spent_month, non_null(:integer))
field(:credits_remaining_month, non_null(:integer))
field(:queries_executed_month, non_null(:integer))
Expand Down
34 changes: 34 additions & 0 deletions livebooks/gather_alerts_info.livemd
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Untitled notebook

## Section

```elixir
type = "metric_signal"
alerts = Sanbase.Alert.UserTrigger.get_all_triggers_by_type(type)

IO.puts("Got #{length(alerts)} alerts")
```

```elixir
data =
alerts
|> Enum.take(2)
|> Enum.map(fn alert ->
%{
alert_id: alert.id,
user_id: alert.user_id,
inserted_at: alert.inserted_at,
updated_at: alert.updated_at,
metric: alert.trigger.settings.metric,
target: alert.trigger.settings.target,
channels: alert.trigger.settings.channel |> List.wrap()
}
end)
```

```elixir
json = Jason.encode!(data)

Path.expand("~/alerts_data.json")
|> File.write!(json)
```
6 changes: 3 additions & 3 deletions test/sanbase_web/graphql/queries/queries_api_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ defmodule SanbaseWeb.Graphql.QueriesApiTest do
|> get_in(["data", "currentUser", "queriesExecutionsInfo"])

assert stats == %{
"creditsAvailalbeMonth" => 500,
"creditsAvailableMonth" => 500,
"creditsRemainingMonth" => 499,
"creditsSpentMonth" => 1,
"queriesExecutedDay" => 1,
Expand Down Expand Up @@ -334,7 +334,7 @@ defmodule SanbaseWeb.Graphql.QueriesApiTest do
assert Process.get(:queries_dynamic_repo) == Sanbase.ClickhouseRepo.BusinessMaxUser

assert stats == %{
"creditsAvailalbeMonth" => 500_000,
"creditsAvailableMonth" => 500_000,
"creditsRemainingMonth" => 499_999,
"creditsSpentMonth" => 1,
"queriesExecutedDay" => 1,
Expand All @@ -357,7 +357,7 @@ defmodule SanbaseWeb.Graphql.QueriesApiTest do
currentUser {
queriesExecutionsInfo {
# credits info
creditsAvailalbeMonth
creditsAvailableMonth
creditsSpentMonth
creditsRemainingMonth
# queries executed
Expand Down

0 comments on commit 0ffdea9

Please sign in to comment.