Skip to content

Commit

Permalink
Use last_login_timex
Browse files Browse the repository at this point in the history
  • Loading branch information
jauggy committed Dec 16, 2024
1 parent b130d7e commit 9714f89
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/teiserver/account/libs/account_test_lib.ex
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ defmodule Teiserver.Account.AccountTestLib do
email: data["email"] || "email_#{r}",
colour: data["colour"] || "colour",
icon: data["icon"] || "icon",
last_login: data["last_login"] || Timex.now()
last_login_timex: data["last_login_timex"] || Timex.now()
},
:script
)
Expand Down
4 changes: 2 additions & 2 deletions lib/teiserver/account/libs/relationship_lib.ex
Original file line number Diff line number Diff line change
Expand Up @@ -397,8 +397,8 @@ defmodule Teiserver.Account.RelationshipLib do
using account_users au
where au.id = ar.to_user_id
and ar.from_user_id = $1
and (au.last_login is null OR
abs(DATE_PART('day', (now()- au.last_login ))) > $2);
and (au.last_login_timex is null OR
abs(DATE_PART('day', (now()- au.last_login_timex ))) > $2);
"""

results =
Expand Down
4 changes: 2 additions & 2 deletions lib/teiserver_web/live/account/relationship/index.ex
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ defmodule TeiserverWeb.Account.RelationshipLive.Index do

num_friends_deleted =
Enum.map(friends, fn friend ->
last_login = friend.other_user.last_login
last_login = friend.other_user.last_login_timex
days = get_days_diff(last_login, now)
should_delete? = days > days_cutoff

Expand Down Expand Up @@ -514,7 +514,7 @@ defmodule TeiserverWeb.Account.RelationshipLive.Index do

defp get_inactive_friend_count(friends, days_cutoff) do
Enum.filter(friends, fn friend ->
last_login = friend.other_user.last_login
last_login = friend.other_user.last_login_timex
days = get_days_diff(last_login, Timex.now())
days > days_cutoff
end)
Expand Down
4 changes: 1 addition & 3 deletions test/teiserver/account/relationship_lib_test.exs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
defmodule Teiserver.Account.RelationshipLibTest do
use Teiserver.DataCase, async: true
alias Teiserver.Account
alias Teiserver.Account.FriendLib

alias Teiserver.Account.AccountTestLib
alias Teiserver.Account.RelationshipLib
Expand All @@ -15,7 +13,7 @@ defmodule Teiserver.Account.RelationshipLibTest do

user3 =
AccountTestLib.user_fixture(%{
"last_login" => old_login
"last_login_timex" => old_login
})

assert user1.id != nil
Expand Down

0 comments on commit 9714f89

Please sign in to comment.