Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
hrefhref committed Aug 15, 2018
2 parents f8bbfdd + 824b198 commit b5c3da5
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 64 deletions.
121 changes: 67 additions & 54 deletions assets/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions assets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
},
"dependencies": {
"bootstrap": "^4.1.1",
"d3": "^5.1.0",
"d3": "^5.4.0",
"jquery": "^3.3.1",
"metrics-graphics": "^2.14.0",
"moment": "^2.22.1",
"metrics-graphics": "^2.15.6",
"moment": "^2.22.2",
"moment-timezone": "^0.5.17",
"phoenix": "file:../deps/phoenix",
"phoenix_html": "file:../deps/phoenix_html",
Expand All @@ -21,7 +21,7 @@
"devDependencies": {
"babel-brunch": "6.1.1",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-preset-env": "^1.6.1",
"babel-preset-env": "^1.7.0",
"brunch": "2.10.9",
"clean-css-brunch": "2.10.0",
"uglify-js-brunch": "2.10.0"
Expand Down
9 changes: 9 additions & 0 deletions config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ config :fd, Fd.Cache,
config :fd, Fd.Repo,
loggers: [Fd.Repo.Instrumenter, Ecto.LogEntry]

config :sentry,
dsn: "https://edfc2:[email protected]/42",
environment_name: Mix.env(),
enable_source_code_context: true,
root_source_code_path: File.cwd!,
tags: %{
env: "production"
},
included_environments: [:prod]
# Import environment specific config. This must remain at the bottom
# of this file so it overrides the configuration defined above.
import_config "#{Mix.env}.exs"
10 changes: 10 additions & 0 deletions config/prod.exs
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,14 @@ config :fd, :delays,
instance_monitor_calm: 15,
instance_dead: {:hour, 336}

config :sentry,
dsn: "https://[email protected]/1",
environment_name: :prod,
included_environments: [:prod],
enable_source_code_context: true,
root_source_code_path: File.cwd!,
tags: %{
env: "production"
}

import_config "prod.secret.exs"
14 changes: 8 additions & 6 deletions lib/fd/global_stats.ex
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,11 @@ defmodule Fd.GlobalStats do
|> Enum.reduce(%{}, &per_server_reducer/2)

[total, users, statuses, emojis] = from(i in Instance, select: [count(i.id), sum(i.users), sum(i.statuses), sum(i.emojis)])
|> Repo.one
|> Repo.one
|> Enum.map(fn x -> if x == nil, do: 0, else: x end)
[up, up_users, up_statuses, up_emojis] = from(i in Instance, where: i.up == true, select: [count(i.id), sum(i.users), sum(i.statuses), sum(i.emojis)])
|> Repo.one
|> Repo.one
|> Enum.map(fn x -> if x == nil, do: 0, else: x end)

per_server = Enum.reduce(per_server_all, %{}, fn({server_id, x=[total, users, statuses, emojis]}, acc) ->
[up, up_users, up_statuses, up_emojis] = Map.get(per_server_up, server_id, [0, 0, 0, 0])
Expand All @@ -86,10 +88,10 @@ defmodule Fd.GlobalStats do
Logger.info "up_users: #{inspect up_users}"

%{
"instances" => %{"total" => total, "up" => up, "down" => total-(up || 0)},
"users" => %{"total" => users, "up" => up_users, "down" => users-(up_users || 0)},
"statuses" => %{"total" => statuses, "up" => up_statuses, "down" => statuses-(up_statuses || 0)},
"emojis" => %{"total" => emojis, "up" => up_emojis, "down" => emojis-(up_emojis || 0)},
"instances" => %{"total" => total, "up" => up, "down" => total - up },
"users" => %{"total" => users, "up" => up_users, "down" => users - up_users},
"statuses" => %{"total" => statuses, "up" => up_statuses, "down" => statuses - up_statuses},
"emojis" => %{"total" => emojis, "up" => up_emojis, "down" => emojis - up_emojis},
"per_server" => per_server
}
end
Expand Down

0 comments on commit b5c3da5

Please sign in to comment.