Skip to content

Commit

Permalink
Fix server_day_log_lib
Browse files Browse the repository at this point in the history
  • Loading branch information
L-e-x-o-n committed Jul 30, 2024
1 parent 01db91b commit 7fee5d7
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/teiserver/logging/lib/server_day_log_lib.ex
Original file line number Diff line number Diff line change
Expand Up @@ -104,23 +104,23 @@ defmodule Teiserver.Logging.ServerDayLogLib do
def aggregate_day_logs(logs) do
logs
|> Enum.reduce(@empty_log, fn log, acc ->
extend_segment(acc, log)
extend_segment(acc, {log})
end)
|> calculate_aggregates()
end

# Given an existing segment and a batch of logs, calculate the segment and add them together
defp extend_segment(existing, {%{data: data} = _server_log, %{data: activity} = _activity_log}) do
defp extend_segment(existing, {%{data: data} = _server_log}) do
%{
# Used to make calculating the end of day stats easier, this will not appear in the final result
tmp_reduction: %{
battles: existing.tmp_reduction.battles + get_in(data, ~w(aggregates stats battles)),
unique_users:
existing.tmp_reduction.unique_users ++
Map.keys(activity["total"]),
existing.tmp_reduction.unique_users ||
0 + get_in(data, ~w(aggregates stats unique_users)),
unique_players:
existing.tmp_reduction.unique_players ++
Map.keys(activity["player"]),
existing.tmp_reduction.unique_players ||
0 + get_in(data, ~w(aggregates stats unique_players)),
accounts_created:
existing.tmp_reduction.accounts_created +
get_in(data, ~w(aggregates stats accounts_created)),
Expand Down

0 comments on commit 7fee5d7

Please sign in to comment.