projects
/
akkoma
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
admin api: added user filters by `actor_types`
[akkoma]
/
lib
/
pleroma
/
web
/
admin_api
/
controllers
/
media_proxy_cache_controller.ex
diff --git
a/lib/pleroma/web/admin_api/controllers/media_proxy_cache_controller.ex
b/lib/pleroma/web/admin_api/controllers/media_proxy_cache_controller.ex
index 76d3af4efccac79edcd8a1fc32faf46bc6ae365a..6d92e9f7ffdc376e82cd8b1450de3a361d84a1c2 100644
(file)
--- a/
lib/pleroma/web/admin_api/controllers/media_proxy_cache_controller.ex
+++ b/
lib/pleroma/web/admin_api/controllers/media_proxy_cache_controller.ex
@@
-5,9
+5,9
@@
defmodule Pleroma.Web.AdminAPI.MediaProxyCacheController do
use Pleroma.Web, :controller
defmodule Pleroma.Web.AdminAPI.MediaProxyCacheController do
use Pleroma.Web, :controller
- alias Pleroma.Plugs.OAuthScopesPlug
alias Pleroma.Web.ApiSpec.Admin, as: Spec
alias Pleroma.Web.MediaProxy
alias Pleroma.Web.ApiSpec.Admin, as: Spec
alias Pleroma.Web.MediaProxy
+ alias Pleroma.Web.Plugs.OAuthScopesPlug
plug(Pleroma.Web.ApiSpec.CastAndValidate)
plug(Pleroma.Web.ApiSpec.CastAndValidate)
@@
-38,18
+38,20
@@
defmodule Pleroma.Web.AdminAPI.MediaProxyCacheController do
defp fetch_entries(params) do
MediaProxy.cache_table()
defp fetch_entries(params) do
MediaProxy.cache_table()
- |> Cachex.
export!(
)
- |> filter_
url
s(params[:query])
+ |> Cachex.
stream!(Cachex.Query.create(true, :key)
)
+ |> filter_
entrie
s(params[:query])
end
end
- defp filter_urls(entries, query) when is_binary(query) do
- for {_, url, _, _, _} <- entries, String.contains?(url, query), do: url
- end
+ defp filter_entries(stream, query) when is_binary(query) do
+ regex = ~r/#{query}/i
- defp filter_urls(entries, _) do
- Enum.map(entries, fn {_, url, _, _, _} -> url end)
+ stream
+ |> Enum.filter(fn url -> String.match?(url, regex) end)
+ |> Enum.to_list()
end
end
+ defp filter_entries(stream, _), do: Enum.to_list(stream)
+
defp paginate_entries(entries, page, page_size) do
offset = page_size * (page - 1)
Enum.slice(entries, offset, page_size)
defp paginate_entries(entries, page, page_size) do
offset = page_size * (page - 1)
Enum.slice(entries, offset, page_size)