mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-11-25 15:39:19 +00:00
fix compatibility with meilisearch (#164)
Reviewed-on: https://akkoma.dev/AkkomaGang/akkoma/pulls/164
This commit is contained in:
parent
37a1001b97
commit
61641957cb
|
@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Compatibility with latest meilisearch
|
||||||
|
- Resolution of nested mix tasks (i.e search.meilisearch) in OTP releases
|
||||||
|
|
||||||
### Removed
|
### Removed
|
||||||
- Non-finch HTTP adapters. `:tesla, :adapter` is now highly recommended to be set to the default.
|
- Non-finch HTTP adapters. `:tesla, :adapter` is now highly recommended to be set to the default.
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ defmodule Mix.Tasks.Pleroma.Search.Meilisearch do
|
||||||
import Ecto.Query
|
import Ecto.Query
|
||||||
|
|
||||||
import Pleroma.Search.Meilisearch,
|
import Pleroma.Search.Meilisearch,
|
||||||
only: [meili_post: 2, meili_put: 2, meili_get: 1, meili_delete!: 1]
|
only: [meili_put: 2, meili_get: 1, meili_delete!: 1]
|
||||||
|
|
||||||
def run(["index"]) do
|
def run(["index"]) do
|
||||||
start_pleroma()
|
start_pleroma()
|
||||||
|
@ -27,7 +27,7 @@ defmodule Mix.Tasks.Pleroma.Search.Meilisearch do
|
||||||
end
|
end
|
||||||
|
|
||||||
{:ok, _} =
|
{:ok, _} =
|
||||||
meili_post(
|
meili_put(
|
||||||
"/indexes/objects/settings/ranking-rules",
|
"/indexes/objects/settings/ranking-rules",
|
||||||
[
|
[
|
||||||
"published:desc",
|
"published:desc",
|
||||||
|
@ -41,7 +41,7 @@ defmodule Mix.Tasks.Pleroma.Search.Meilisearch do
|
||||||
)
|
)
|
||||||
|
|
||||||
{:ok, _} =
|
{:ok, _} =
|
||||||
meili_post(
|
meili_put(
|
||||||
"/indexes/objects/settings/searchable-attributes",
|
"/indexes/objects/settings/searchable-attributes",
|
||||||
[
|
[
|
||||||
"content"
|
"content"
|
||||||
|
@ -91,7 +91,7 @@ defmodule Mix.Tasks.Pleroma.Search.Meilisearch do
|
||||||
)
|
)
|
||||||
|
|
||||||
with {:ok, res} <- result do
|
with {:ok, res} <- result do
|
||||||
if not Map.has_key?(res, "uid") do
|
if not Map.has_key?(res, "indexUid") do
|
||||||
IO.puts("\nFailed to index: #{inspect(result)}")
|
IO.puts("\nFailed to index: #{inspect(result)}")
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
|
|
@ -25,7 +25,7 @@ defmodule Pleroma.ReleaseTasks do
|
||||||
module = Module.split(module)
|
module = Module.split(module)
|
||||||
|
|
||||||
match?(["Mix", "Tasks", "Pleroma" | _], module) and
|
match?(["Mix", "Tasks", "Pleroma" | _], module) and
|
||||||
String.downcase(List.last(module)) == task
|
task_match?(module, task)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
if module do
|
if module do
|
||||||
|
@ -35,6 +35,13 @@ defmodule Pleroma.ReleaseTasks do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp task_match?(["Mix", "Tasks", "Pleroma" | module_path], task) do
|
||||||
|
module_path
|
||||||
|
|> Enum.join(".")
|
||||||
|
|> String.downcase()
|
||||||
|
|> String.equivalent?(String.downcase(task))
|
||||||
|
end
|
||||||
|
|
||||||
def migrate(args) do
|
def migrate(args) do
|
||||||
Mix.Tasks.Pleroma.Ecto.Migrate.run(args)
|
Mix.Tasks.Pleroma.Ecto.Migrate.run(args)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue