diff options
author | Simponic <loganhunt@simponic.xyz> | 2023-01-20 23:12:23 -0700 |
---|---|---|
committer | Simponic <loganhunt@simponic.xyz> | 2023-01-20 23:12:23 -0700 |
commit | 06f1ca76037397fb61c69319802ed029ac73e715 (patch) | |
tree | 37cdf1ebf5fcbaefda58d377bb6b4e3a8a11410b /lib/chessh/schema | |
parent | e0058fedfb191db8802a95548cbaf96b6fe58f80 (diff) | |
download | chessh-06f1ca76037397fb61c69319802ed029ac73e715.tar.gz chessh-06f1ca76037397fb61c69319802ed029ac73e715.zip |
Add pagination menus
Diffstat (limited to 'lib/chessh/schema')
-rw-r--r-- | lib/chessh/schema/player_session.ex | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/chessh/schema/player_session.ex b/lib/chessh/schema/player_session.ex index f12387a..cb06715 100644 --- a/lib/chessh/schema/player_session.ex +++ b/lib/chessh/schema/player_session.ex @@ -86,10 +86,7 @@ defmodule Chessh.PlayerSession do "Player #{player.username} has #{length(expired_sessions)} expired sessions - attempting to close them" ) - Enum.map(expired_sessions, fn session_id -> - :syn.publish(:player_sessions, {:session, session_id}, :session_closed) - end) - + Enum.map(expired_sessions, &close_session/1) Repo.delete_all(from(p in PlayerSession, where: p.id in ^expired_sessions)) end @@ -112,8 +109,13 @@ defmodule Chessh.PlayerSession do def close_all_player_sessions(player) do player_sessions = Repo.all(from(p in PlayerSession, where: p.player_id == ^player.id)) - Enum.map(player_sessions, fn session -> - :syn.publish(:player_sessions, {:session, session.id}, :session_closed) - end) + Enum.map(player_sessions, &close_session(&1.id)) + end + + defp close_session(id) do + case :syn_backbone.get_table_name(:syn_pg_by_name, :player_sessions) do + :undefined -> nil + _ -> :syn.publish(:player_sessions, {:session, id}, :session_closed) + end end end |