Skip to content
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

Minor improvements to whoami and whois commands #333

Merged
Merged
Changes from 1 commit
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
14 changes: 10 additions & 4 deletions lib/teiserver/coordinator/coordinator_commands.ex
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,12 @@ defmodule Teiserver.Coordinator.CoordinatorCommands do
sender = CacheUser.get_user_by_id(senderid)
stats = Account.get_user_stat_data(senderid)

total_hours = (Map.get(stats, "total_minutes", 0) / 60) |> round
player_hours = (Map.get(stats, "player_minutes", 0) / 60) |> round
spectator_hours = (Map.get(stats, "spectator_minutes", 0) / 60) |> round
# Hours should be rounded down to make it more
# accurate for determining if a chevron threshold is reached
total_hours = (Map.get(stats, "total_minutes", 0) / 60) |> trunc
player_hours = (Map.get(stats, "player_minutes", 0) / 60) |> trunc
spectator_hours = (Map.get(stats, "spectator_minutes", 0) / 60) |> trunc
lobby_hours = (Map.get(stats, "lobby_minutes", 0) / 60) |> trunc

host = Application.get_env(:teiserver, TeiserverWeb.Endpoint)[:url][:host]
profile_link = "https://#{host}/profile/#{senderid}"
Expand Down Expand Up @@ -197,7 +200,7 @@ defmodule Teiserver.Coordinator.CoordinatorCommands do
[
@splitter,
"You are #{sender.name}",
"Playtime: #{total_hours} hours (#{player_hours} h playing, #{spectator_hours} h spectating)",
"#{total_hours} total hours (#{player_hours} h playing, #{spectator_hours} h spectating, #{lobby_hours} h in lobby)",
"Profile link: #{profile_link}",
"Skill ratings:",
ratings,
Expand Down Expand Up @@ -275,11 +278,14 @@ defmodule Teiserver.Coordinator.CoordinatorCommands do
end)
|> Enum.sort()

chevron_level = Map.get(stats, "rank", 0) + 1

standard_parts = [
@splitter,
"Found #{user.name}",
if(previous_names != "", do: "Previous names: #{previous_names}"),
"Profile link: #{profile_link}",
"Chevron level: #{chevron_level}",
["Ratings:" | ratings],
moderation_data,
@splitter
Expand Down
Loading