mirror of
https://github.com/TheRealOwenRees/chess-endgame-trainer.git
synced 2026-11-18 11:42:07 +00:00
show logged-in player count in landing hero
Count distinct users with a session token valid within the 14-day window and use it for the hero players-training stat. The learning strip keeps the total player count. Also load the split seed modules in seeds_test and drop an invalid 8-piece seed FEN so precommit passes.
This commit is contained in:
@@ -583,6 +583,25 @@ defmodule Chesstrainer.AccountsTest do
|
||||
end
|
||||
end
|
||||
|
||||
describe "count_logged_in_users/0" do
|
||||
test "counts distinct users with a valid session token" do
|
||||
user = user_fixture()
|
||||
_ = Accounts.generate_user_session_token(user)
|
||||
_ = Accounts.generate_user_session_token(user)
|
||||
_other = Accounts.generate_user_session_token(user_fixture())
|
||||
|
||||
assert Accounts.count_logged_in_users() == 2
|
||||
end
|
||||
|
||||
test "ignores expired session tokens" do
|
||||
user = user_fixture()
|
||||
user_token = Accounts.generate_user_session_token(user)
|
||||
offset_user_token(user_token, -15, :day)
|
||||
|
||||
assert Accounts.count_logged_in_users() == 0
|
||||
end
|
||||
end
|
||||
|
||||
describe "delete_user/1" do
|
||||
test "deletes the user and their session tokens" do
|
||||
user = user_fixture()
|
||||
|
||||
@@ -3,6 +3,8 @@ defmodule Chesstrainer.SeedsTest do
|
||||
|
||||
alias Chesstrainer.FEN
|
||||
|
||||
Code.require_file("../../priv/repo/seeds/endgames/win.ex", __DIR__)
|
||||
Code.require_file("../../priv/repo/seeds/endgames/draw.ex", __DIR__)
|
||||
Code.require_file("../../priv/repo/seeds/endgames.ex", __DIR__)
|
||||
|
||||
describe "seed endgames" do
|
||||
|
||||
Reference in New Issue
Block a user