Removed users.info and remaining usages.
authorIvan Tashkinov <ivantashkinov@gmail.com>
Sat, 23 Nov 2019 11:06:19 +0000 (14:06 +0300)
committerIvan Tashkinov <ivantashkinov@gmail.com>
Sat, 23 Nov 2019 11:06:19 +0000 (14:06 +0300)
benchmarks/load_testing/generator.ex
lib/pleroma/user.ex
priv/repo/migrations/20191123103423_remove_info_from_users.exs [new file with mode: 0644]
test/support/factory.ex
test/user_test.exs

index b4432bdb7313621dc92c5d97583cdc00082864c7..4505d192faf38b574c0adacf60dd4731e4f195d3 100644 (file)
@@ -31,7 +31,6 @@ defmodule Pleroma.LoadTesting.Generator do
       password_hash:
         "$pbkdf2-sha512$160000$bU.OSFI7H/yqWb5DPEqyjw$uKp/2rmXw12QqnRRTqTtuk2DTwZfF8VR4MYW2xMeIlqPR/UX1nT1CEKVUx2CowFMZ5JON8aDvURrZpJjSgqXrg",
       bio: "Tester Number #{i}",
-      info: %{},
       local: remote
     }
 
index fcb1d5143942bc7738aff01ca8ecf70ca7166181..e4656af3dad3f80461a9744341b21c1250c779be 100644 (file)
@@ -119,8 +119,6 @@ defmodule Pleroma.User do
     has_many(:registrations, Registration)
     has_many(:deliveries, Delivery)
 
-    field(:info, :map, default: %{})
-
     timestamps()
   end
 
@@ -244,7 +242,6 @@ defmodule Pleroma.User do
 
     params =
       params
-      |> Map.put(:info, params[:info] || %{})
       |> truncate_if_exists(:name, name_limit)
       |> truncate_if_exists(:bio, bio_limit)
       |> truncate_fields_param()
@@ -1226,7 +1223,7 @@ defmodule Pleroma.User do
   def external_users(opts \\ []) do
     query =
       external_users_query()
-      |> select([u], struct(u, [:id, :ap_id, :info]))
+      |> select([u], struct(u, [:id, :ap_id]))
 
     query =
       if opts[:max_id],
diff --git a/priv/repo/migrations/20191123103423_remove_info_from_users.exs b/priv/repo/migrations/20191123103423_remove_info_from_users.exs
new file mode 100644 (file)
index 0000000..b251255
--- /dev/null
@@ -0,0 +1,9 @@
+defmodule Pleroma.Repo.Migrations.RemoveInfoFromUsers do
+  use Ecto.Migration
+
+  def change do
+    alter table(:users) do
+      remove(:info, :map, default: %{})
+    end
+  end
+end
index e3f797f64c16b4abb0dcc8f05ada8cd8a811479f..bb8a64e7243816e5b9a036e25ec458311eda8c72 100644 (file)
@@ -31,7 +31,6 @@ defmodule Pleroma.Factory do
       nickname: sequence(:nickname, &"nick#{&1}"),
       password_hash: Comeonin.Pbkdf2.hashpwsalt("test"),
       bio: sequence(:bio, &"Tester Number #{&1}"),
-      info: %{},
       last_digest_emailed_at: NaiveDateTime.utc_now()
     }
 
index 8fdb6b25fc2f2bba9916d8bfdc32c4924fb00bf4..e07ddd097a56c9b5c6cb878c850bd29c4dd2b1d6 100644 (file)
@@ -347,18 +347,6 @@ defmodule Pleroma.UserTest do
 
       assert changeset.changes.follower_address == "#{changeset.changes.ap_id}/followers"
     end
-
-    test "it ensures info is not nil" do
-      changeset = User.register_changeset(%User{}, @full_user_data)
-
-      assert changeset.valid?
-
-      {:ok, user} =
-        changeset
-        |> Repo.insert()
-
-      refute is_nil(user.info)
-    end
   end
 
   describe "user registration, with :account_activation_required" do
@@ -412,8 +400,7 @@ defmodule Pleroma.UserTest do
           :user,
           local: false,
           nickname: "admin@mastodon.example.org",
-          ap_id: ap_id,
-          info: %{}
+          ap_id: ap_id
         )
 
       {:ok, fetched_user} = User.get_or_fetch(ap_id)
@@ -474,8 +461,7 @@ defmodule Pleroma.UserTest do
           local: false,
           nickname: "admin@mastodon.example.org",
           ap_id: "http://mastodon.example.org/users/admin",
-          last_refreshed_at: a_week_ago,
-          info: %{}
+          last_refreshed_at: a_week_ago
         )
 
       assert orig_user.last_refreshed_at == a_week_ago
@@ -516,7 +502,6 @@ defmodule Pleroma.UserTest do
       name: "Someone",
       nickname: "a@b.de",
       ap_id: "http...",
-      info: %{some: "info"},
       avatar: %{some: "avatar"}
     }
 
@@ -1121,8 +1106,7 @@ defmodule Pleroma.UserTest do
         ap_id: user.ap_id,
         name: user.name,
         nickname: user.nickname,
-        bio: String.duplicate("h", current_max_length + 1),
-        info: %{}
+        bio: String.duplicate("h", current_max_length + 1)
       }
 
       assert {:ok, %User{}} = User.insert_or_update_user(data)
@@ -1135,8 +1119,7 @@ defmodule Pleroma.UserTest do
       data = %{
         ap_id: user.ap_id,
         name: String.duplicate("h", current_max_length + 1),
-        nickname: user.nickname,
-        info: %{}
+        nickname: user.nickname
       }
 
       assert {:ok, %User{}} = User.insert_or_update_user(data)