diff --git a/lib/ret/media_search.ex b/lib/ret/media_search.ex index f47a3a57e..77413aadd 100644 --- a/lib/ret/media_search.ex +++ b/lib/ret/media_search.ex @@ -41,7 +41,7 @@ defmodule Ret.MediaSearch do @max_collection_face_count 200_000 # see sketchfab bug about max_filesizes params broken - # @max_file_size_bytes 20 * 1024 * 1024 + # @max_file_size_bytes 20 * 1024 * 1024 # @max_collection_file_size_bytes 100 * 1024 * 1024 def search(%Ret.MediaSearchQuery{ @@ -125,6 +125,10 @@ defmodule Ret.MediaSearch do public_rooms_search(cursor, q) end + def search(%Ret.MediaSearchQuery{source: "rooms", filter: "created", cursor: cursor, q: q}) do + created_rooms_search(cursor, q) + end + def search(%Ret.MediaSearchQuery{ source: "sketchfab", cursor: cursor, @@ -225,7 +229,7 @@ defmodule Ret.MediaSearch do downloadable: true, count: @page_size, max_face_count: @max_face_count, - # max_filesizes: "gltf:#{@max_file_size_bytes}", + # max_filesizes: "gltf:#{@max_file_size_bytes}", processing_status: :succeeded, cursor: cursor, categories: filter, @@ -547,6 +551,25 @@ defmodule Ret.MediaSearch do {:commit, results} end + defp created_rooms_search(cursor, _query) do + page_number = (cursor || "1") |> Integer.parse() |> elem(0) + + ecto_query = + from h in Hub, + preload: [ + scene: [:screenshot_owned_file], + scene_listing: [:scene, :screenshot_owned_file] + ], + order_by: [desc: :inserted_at] + + results = + ecto_query + |> Repo.paginate(%{page: page_number, page_size: @page_size}) + |> result_for_page(page_number, :my_rooms, &hub_to_entry/1) + + {:commit, results} + end + defp filter_by_hub_entry_mode(query, entry_mode) do from fav in query, join: hub in assoc(fav, :hub),