forked from AkkomaGang/akkoma
Search: Save detected pg version in a persistent term.
This commit is contained in:
parent
f9a4cf2097
commit
67b15cc033
4 changed files with 8 additions and 8 deletions
|
@ -20,7 +20,7 @@ def search(user, search_query, options \\ []) do
|
||||||
author = Keyword.get(options, :author)
|
author = Keyword.get(options, :author)
|
||||||
|
|
||||||
search_function =
|
search_function =
|
||||||
if Application.get_env(:postgres, :version) >= 11 do
|
if :persistent_term.get({Pleroma.Repo, :postgres_version}) >= 11 do
|
||||||
:websearch
|
:websearch
|
||||||
else
|
else
|
||||||
:plain
|
:plain
|
||||||
|
|
|
@ -131,7 +131,7 @@ defp set_postgres_server_version do
|
||||||
9.6
|
9.6
|
||||||
end
|
end
|
||||||
|
|
||||||
Application.put_env(:postgres, :version, version)
|
:persistent_term.put({Pleroma.Repo, :postgres_version}, version)
|
||||||
end
|
end
|
||||||
|
|
||||||
def load_custom_modules do
|
def load_custom_modules do
|
||||||
|
|
|
@ -19,8 +19,8 @@ test "it finds something" do
|
||||||
end
|
end
|
||||||
|
|
||||||
test "using plainto_tsquery on postgres < 11" do
|
test "using plainto_tsquery on postgres < 11" do
|
||||||
old_config = Application.get_env(:postgres, :version)
|
old_version = :persistent_term.get({Pleroma.Repo, :postgres_version})
|
||||||
Application.put_env(:postgres, :version, 10.0)
|
:persistent_term.put({Pleroma.Repo, :postgres_version}, 10.0)
|
||||||
|
|
||||||
user = insert(:user)
|
user = insert(:user)
|
||||||
{:ok, post} = CommonAPI.post(user, %{status: "it's wednesday my dudes"})
|
{:ok, post} = CommonAPI.post(user, %{status: "it's wednesday my dudes"})
|
||||||
|
@ -31,7 +31,7 @@ test "using plainto_tsquery on postgres < 11" do
|
||||||
|
|
||||||
assert result.id == post.id
|
assert result.id == post.id
|
||||||
|
|
||||||
Application.put_env(:postgres, :version, old_config)
|
:persistent_term.put({Pleroma.Repo, :postgres_version}, old_version)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "using websearch_to_tsquery" do
|
test "using websearch_to_tsquery" do
|
||||||
|
|
|
@ -279,8 +279,8 @@ test "search", %{conn: conn} do
|
||||||
end
|
end
|
||||||
|
|
||||||
test "search fetches remote statuses and prefers them over other results", %{conn: conn} do
|
test "search fetches remote statuses and prefers them over other results", %{conn: conn} do
|
||||||
old_config = Application.get_env(:postgres, :version)
|
old_version = :persistent_term.get({Pleroma.Repo, :postgres_version})
|
||||||
Application.put_env(:postgres, :version, 10.0)
|
:persistent_term.put({Pleroma.Repo, :postgres_version}, 10.0)
|
||||||
|
|
||||||
capture_log(fn ->
|
capture_log(fn ->
|
||||||
{:ok, %{id: activity_id}} =
|
{:ok, %{id: activity_id}} =
|
||||||
|
@ -299,7 +299,7 @@ test "search fetches remote statuses and prefers them over other results", %{con
|
||||||
] = results["statuses"]
|
] = results["statuses"]
|
||||||
end)
|
end)
|
||||||
|
|
||||||
Application.put_env(:postgres, :version, old_config)
|
:persistent_term.put({Pleroma.Repo, :postgres_version}, old_version)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "search doesn't show statuses that it shouldn't", %{conn: conn} do
|
test "search doesn't show statuses that it shouldn't", %{conn: conn} do
|
||||||
|
|
Loading…
Reference in a new issue