-
Notifications
You must be signed in to change notification settings - Fork 233
change the approach to obtaining user statistics data #2183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
end | ||
|
||
defp calculate_stats(user_games) do | ||
total_games = length(user_games) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's get all these count in SQL query
stats = calculate_stats(user_games) | ||
|
||
case Repo.get_by(UserGameStatistics, user_id: user_id) do | ||
nil -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let' write insert on conflict (user_id) update
field :total_losses, :integer | ||
field :total_giveups, :integer, default: 0 | ||
field :versus_bot_games, :integer | ||
field :versus_human_games, :integer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need versus_bot_games and versus_human_games?
@@ -332,6 +332,10 @@ defmodule Codebattle.Game.Engine do | |||
}) | |||
|
|||
update_user!(player) | |||
|
|||
unless player.is_bot or player.is_guest do | |||
Codebattle.UserGameStatistics.Context.update_user_stats(player.id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's do it async
Closes #2182