mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-12-23 17:54:22 +00:00
Add the meilisearch.stats command
This commit is contained in:
parent
d5cc272a91
commit
d1079f1aa3
|
@ -9,7 +9,7 @@ defmodule Mix.Tasks.Pleroma.Search.Meilisearch do
|
||||||
import Mix.Pleroma
|
import Mix.Pleroma
|
||||||
import Ecto.Query
|
import Ecto.Query
|
||||||
|
|
||||||
import Pleroma.Search.Meilisearch, only: [meili_post!: 2, meili_delete!: 1]
|
import Pleroma.Search.Meilisearch, only: [meili_post!: 2, meili_delete!: 1, meili_get!: 1]
|
||||||
|
|
||||||
def run(["index"]) do
|
def run(["index"]) do
|
||||||
start_pleroma()
|
start_pleroma()
|
||||||
|
@ -111,4 +111,12 @@ defmodule Mix.Tasks.Pleroma.Search.Meilisearch do
|
||||||
IO.puts("Error fetching the key, check the master key is correct: #{inspect(decoded)}")
|
IO.puts("Error fetching the key, check the master key is correct: #{inspect(decoded)}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def run(["stats"]) do
|
||||||
|
start_pleroma()
|
||||||
|
|
||||||
|
result = meili_get!("/indexes/objects/stats")
|
||||||
|
IO.puts("Number of entries: #{result["numberOfDocuments"]}")
|
||||||
|
IO.puts("Indexing? #{result["isIndexing"]}")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -13,6 +13,18 @@ defmodule Pleroma.Search.Meilisearch do
|
||||||
if is_nil(private_key), do: [], else: [{"X-Meili-API-Key", private_key}]
|
if is_nil(private_key), do: [], else: [{"X-Meili-API-Key", private_key}]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def meili_get!(path) do
|
||||||
|
endpoint = Pleroma.Config.get([Pleroma.Search.Meilisearch, :url])
|
||||||
|
|
||||||
|
{:ok, result} =
|
||||||
|
Pleroma.HTTP.get(
|
||||||
|
Path.join(endpoint, path),
|
||||||
|
meili_headers()
|
||||||
|
)
|
||||||
|
|
||||||
|
Jason.decode!(result.body)
|
||||||
|
end
|
||||||
|
|
||||||
def meili_post!(path, params) do
|
def meili_post!(path, params) do
|
||||||
endpoint = Pleroma.Config.get([Pleroma.Search.Meilisearch, :url])
|
endpoint = Pleroma.Config.get([Pleroma.Search.Meilisearch, :url])
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue