mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-23 20:18:00 +01:00
mix format
This commit is contained in:
parent
41b3078da8
commit
c65f27a1ff
8 changed files with 98 additions and 19 deletions
|
@ -52,7 +52,9 @@ defmodule Philomena.Elasticsearch do
|
||||||
index_name = index.index_name()
|
index_name = index.index_name()
|
||||||
mapping = index.mapping().mappings.properties
|
mapping = index.mapping().mappings.properties
|
||||||
|
|
||||||
Elastix.Mapping.put(elastic_url(), index_name, "_doc", %{properties: mapping}, include_type_name: true)
|
Elastix.Mapping.put(elastic_url(), index_name, "_doc", %{properties: mapping},
|
||||||
|
include_type_name: true
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def index_document(doc, module) do
|
def index_document(doc, module) do
|
||||||
|
|
|
@ -40,7 +40,12 @@ defmodule Philomena.Processors.Png do
|
||||||
[{:symlink_original, "full.png"}]
|
[{:symlink_original, "full.png"}]
|
||||||
end
|
end
|
||||||
|
|
||||||
defp scale_if_smaller(file, animated?, {width, height}, {thumb_name, {target_width, target_height}}) do
|
defp scale_if_smaller(
|
||||||
|
file,
|
||||||
|
animated?,
|
||||||
|
{width, height},
|
||||||
|
{thumb_name, {target_width, target_height}}
|
||||||
|
) do
|
||||||
if width > target_width or height > target_height do
|
if width > target_width or height > target_height do
|
||||||
scaled = scale(file, animated?, {target_width, target_height})
|
scaled = scale(file, animated?, {target_width, target_height})
|
||||||
|
|
||||||
|
@ -59,7 +64,20 @@ defmodule Philomena.Processors.Png do
|
||||||
{_output, 0} =
|
{_output, 0} =
|
||||||
cond do
|
cond do
|
||||||
animated? ->
|
animated? ->
|
||||||
System.cmd("ffmpeg", ["-loglevel", "0", "-y", "-i", file, "-plays", "0", "-vf", scale_filter, "-f", "apng", scaled])
|
System.cmd("ffmpeg", [
|
||||||
|
"-loglevel",
|
||||||
|
"0",
|
||||||
|
"-y",
|
||||||
|
"-i",
|
||||||
|
file,
|
||||||
|
"-plays",
|
||||||
|
"0",
|
||||||
|
"-vf",
|
||||||
|
scale_filter,
|
||||||
|
"-f",
|
||||||
|
"apng",
|
||||||
|
scaled
|
||||||
|
])
|
||||||
|
|
||||||
true ->
|
true ->
|
||||||
System.cmd("ffmpeg", ["-loglevel", "0", "-y", "-i", file, "-vf", scale_filter, scaled])
|
System.cmd("ffmpeg", ["-loglevel", "0", "-y", "-i", file, "-vf", scale_filter, scaled])
|
||||||
|
|
|
@ -60,7 +60,9 @@ defmodule Philomena.Scrapers.Twitter do
|
||||||
end
|
end
|
||||||
|
|
||||||
defp extract_guest_token_and_bearer(%Tesla.Env{body: page, headers: headers}) do
|
defp extract_guest_token_and_bearer(%Tesla.Env{body: page, headers: headers}) do
|
||||||
[{_, gt}] = Enum.filter(headers, fn {k, v} -> k == "set-cookie" and String.starts_with?(v, "gt=") end)
|
[{_, gt}] =
|
||||||
|
Enum.filter(headers, fn {k, v} -> k == "set-cookie" and String.starts_with?(v, "gt=") end)
|
||||||
|
|
||||||
[gt] = Regex.run(@gt_regex, gt, capture: :all_but_first)
|
[gt] = Regex.run(@gt_regex, gt, capture: :all_but_first)
|
||||||
[script] = Regex.run(@script_regex, page, capture: :all_but_first)
|
[script] = Regex.run(@script_regex, page, capture: :all_but_first)
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,12 @@ defmodule PhilomenaWeb.Image.DescriptionController do
|
||||||
|
|
||||||
plug PhilomenaWeb.FilterBannedUsersPlug
|
plug PhilomenaWeb.FilterBannedUsersPlug
|
||||||
plug PhilomenaWeb.CanaryMapPlug, update: :edit_description
|
plug PhilomenaWeb.CanaryMapPlug, update: :edit_description
|
||||||
plug :load_and_authorize_resource, model: Image, id_name: "image_id", persisted: true, preload: [:tags, :user]
|
|
||||||
|
plug :load_and_authorize_resource,
|
||||||
|
model: Image,
|
||||||
|
id_name: "image_id",
|
||||||
|
persisted: true,
|
||||||
|
preload: [:tags, :user]
|
||||||
|
|
||||||
def update(conn, %{"image" => image_params}) do
|
def update(conn, %{"image" => image_params}) do
|
||||||
image = conn.assigns.image
|
image = conn.assigns.image
|
||||||
|
@ -20,6 +25,7 @@ defmodule PhilomenaWeb.Image.DescriptionController do
|
||||||
"image:description_update",
|
"image:description_update",
|
||||||
%{image_id: image.id, added: image.description, removed: old_description}
|
%{image_id: image.id, added: image.description, removed: old_description}
|
||||||
)
|
)
|
||||||
|
|
||||||
PhilomenaWeb.Endpoint.broadcast!(
|
PhilomenaWeb.Endpoint.broadcast!(
|
||||||
"firehose",
|
"firehose",
|
||||||
"image:update",
|
"image:update",
|
||||||
|
|
|
@ -26,6 +26,7 @@ defmodule PhilomenaWeb.Image.SourceController do
|
||||||
"image:source_update",
|
"image:source_update",
|
||||||
%{image_id: image.id, added: [image.source_url], removed: [old_source]}
|
%{image_id: image.id, added: [image.source_url], removed: [old_source]}
|
||||||
)
|
)
|
||||||
|
|
||||||
PhilomenaWeb.Endpoint.broadcast!(
|
PhilomenaWeb.Endpoint.broadcast!(
|
||||||
"firehose",
|
"firehose",
|
||||||
"image:update",
|
"image:update",
|
||||||
|
|
|
@ -25,8 +25,13 @@ defmodule PhilomenaWeb.Image.TagController do
|
||||||
PhilomenaWeb.Endpoint.broadcast!(
|
PhilomenaWeb.Endpoint.broadcast!(
|
||||||
"firehose",
|
"firehose",
|
||||||
"image:tag_update",
|
"image:tag_update",
|
||||||
%{image_id: image.id, added: Enum.map(added_tags, & &1.name), removed: Enum.map(removed_tags, & &1.name)}
|
%{
|
||||||
|
image_id: image.id,
|
||||||
|
added: Enum.map(added_tags, & &1.name),
|
||||||
|
removed: Enum.map(removed_tags, & &1.name)
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
PhilomenaWeb.Endpoint.broadcast!(
|
PhilomenaWeb.Endpoint.broadcast!(
|
||||||
"firehose",
|
"firehose",
|
||||||
"image:update",
|
"image:update",
|
||||||
|
|
|
@ -2,32 +2,73 @@ defmodule Philomena.Repo.Migrations.ProdSchemaSync20200617 do
|
||||||
use Ecto.Migration
|
use Ecto.Migration
|
||||||
|
|
||||||
def change do
|
def change do
|
||||||
execute("CREATE INDEX index_comments_on_image_id_and_created_at ON public.comments USING btree (image_id, created_at);")
|
execute(
|
||||||
|
"CREATE INDEX index_comments_on_image_id_and_created_at ON public.comments USING btree (image_id, created_at);"
|
||||||
|
)
|
||||||
|
|
||||||
execute("DROP INDEX index_dnp_entries_on_modifying_user_id;")
|
execute("DROP INDEX index_dnp_entries_on_modifying_user_id;")
|
||||||
execute("CREATE INDEX index_dnp_entries_on_aasm_state_filtered ON public.dnp_entries USING btree (aasm_state) WHERE ((aasm_state)::text = ANY (ARRAY[('requested'::character varying)::text, ('claimed'::character varying)::text, ('rescinded'::character varying)::text, ('acknowledged'::character varying)::text]));")
|
|
||||||
execute("CREATE INDEX index_duplicate_reports_on_state_filtered ON public.duplicate_reports USING btree (state) WHERE ((state)::text = ANY (ARRAY[('open'::character varying)::text, ('claimed'::character varying)::text]));")
|
execute(
|
||||||
|
"CREATE INDEX index_dnp_entries_on_aasm_state_filtered ON public.dnp_entries USING btree (aasm_state) WHERE ((aasm_state)::text = ANY (ARRAY[('requested'::character varying)::text, ('claimed'::character varying)::text, ('rescinded'::character varying)::text, ('acknowledged'::character varying)::text]));"
|
||||||
|
)
|
||||||
|
|
||||||
|
execute(
|
||||||
|
"CREATE INDEX index_duplicate_reports_on_state_filtered ON public.duplicate_reports USING btree (state) WHERE ((state)::text = ANY (ARRAY[('open'::character varying)::text, ('claimed'::character varying)::text]));"
|
||||||
|
)
|
||||||
|
|
||||||
execute("CREATE INDEX index_filters_on_name ON public.filters USING btree (name);")
|
execute("CREATE INDEX index_filters_on_name ON public.filters USING btree (name);")
|
||||||
execute("CREATE INDEX index_filters_on_system ON public.filters USING btree (system) WHERE (system = true);")
|
|
||||||
execute("CREATE UNIQUE INDEX index_gallery_interactions_on_gallery_id_and_image_id ON public.gallery_interactions USING btree (gallery_id, image_id);")
|
execute(
|
||||||
execute("CREATE INDEX index_gallery_interactions_on_gallery_id_and_position ON public.gallery_interactions USING btree (gallery_id, \"position\");")
|
"CREATE INDEX index_filters_on_system ON public.filters USING btree (system) WHERE (system = true);"
|
||||||
|
)
|
||||||
|
|
||||||
|
execute(
|
||||||
|
"CREATE UNIQUE INDEX index_gallery_interactions_on_gallery_id_and_image_id ON public.gallery_interactions USING btree (gallery_id, image_id);"
|
||||||
|
)
|
||||||
|
|
||||||
|
execute(
|
||||||
|
"CREATE INDEX index_gallery_interactions_on_gallery_id_and_position ON public.gallery_interactions USING btree (gallery_id, \"position\");"
|
||||||
|
)
|
||||||
|
|
||||||
execute("DROP INDEX index_images_on_first_seen_at;")
|
execute("DROP INDEX index_images_on_first_seen_at;")
|
||||||
execute("DROP INDEX index_notifications_on_actor_id_and_actor_type;")
|
execute("DROP INDEX index_notifications_on_actor_id_and_actor_type;")
|
||||||
execute("CREATE UNIQUE INDEX index_notifications_on_actor_id_and_actor_type ON public.notifications USING btree (actor_id, actor_type);")
|
|
||||||
execute("CREATE INDEX index_subnet_bans_on_specification ON public.subnet_bans USING gist (specification inet_ops);")
|
execute(
|
||||||
execute("CREATE INDEX index_tag_changes_on_fingerprint ON public.tag_changes USING btree (fingerprint);")
|
"CREATE UNIQUE INDEX index_notifications_on_actor_id_and_actor_type ON public.notifications USING btree (actor_id, actor_type);"
|
||||||
execute("CREATE INDEX index_tag_changes_on_ip ON public.tag_changes USING gist (ip inet_ops);")
|
)
|
||||||
|
|
||||||
|
execute(
|
||||||
|
"CREATE INDEX index_subnet_bans_on_specification ON public.subnet_bans USING gist (specification inet_ops);"
|
||||||
|
)
|
||||||
|
|
||||||
|
execute(
|
||||||
|
"CREATE INDEX index_tag_changes_on_fingerprint ON public.tag_changes USING btree (fingerprint);"
|
||||||
|
)
|
||||||
|
|
||||||
|
execute(
|
||||||
|
"CREATE INDEX index_tag_changes_on_ip ON public.tag_changes USING gist (ip inet_ops);"
|
||||||
|
)
|
||||||
|
|
||||||
execute("DROP INDEX index_tags_on_name;")
|
execute("DROP INDEX index_tags_on_name;")
|
||||||
execute("CREATE UNIQUE INDEX index_tags_on_name ON public.tags USING btree (name);")
|
execute("CREATE UNIQUE INDEX index_tags_on_name ON public.tags USING btree (name);")
|
||||||
execute("DROP INDEX index_tags_on_slug;")
|
execute("DROP INDEX index_tags_on_slug;")
|
||||||
execute("CREATE UNIQUE INDEX index_tags_on_slug ON public.tags USING btree (slug);")
|
execute("CREATE UNIQUE INDEX index_tags_on_slug ON public.tags USING btree (slug);")
|
||||||
execute("DROP INDEX index_topics_on_sticky;")
|
execute("DROP INDEX index_topics_on_sticky;")
|
||||||
execute("DROP INDEX index_user_bans_on_created_at;")
|
execute("DROP INDEX index_user_bans_on_created_at;")
|
||||||
execute("CREATE INDEX index_user_bans_on_created_at ON public.user_bans USING btree (created_at DESC);")
|
|
||||||
|
execute(
|
||||||
|
"CREATE INDEX index_user_bans_on_created_at ON public.user_bans USING btree (created_at DESC);"
|
||||||
|
)
|
||||||
|
|
||||||
execute("DROP INDEX index_users_on_name;")
|
execute("DROP INDEX index_users_on_name;")
|
||||||
execute("CREATE UNIQUE INDEX index_users_on_name ON public.users USING btree (name);")
|
execute("CREATE UNIQUE INDEX index_users_on_name ON public.users USING btree (name);")
|
||||||
execute("DROP INDEX index_users_on_slug;")
|
execute("DROP INDEX index_users_on_slug;")
|
||||||
execute("CREATE UNIQUE INDEX index_users_on_slug ON public.users USING btree (slug)")
|
execute("CREATE UNIQUE INDEX index_users_on_slug ON public.users USING btree (slug)")
|
||||||
execute("CREATE INDEX index_users_on_watched_tag_ids ON public.users USING gin (watched_tag_ids);")
|
|
||||||
|
execute(
|
||||||
|
"CREATE INDEX index_users_on_watched_tag_ids ON public.users USING gin (watched_tag_ids);"
|
||||||
|
)
|
||||||
|
|
||||||
execute("DROP INDEX index_adverts_on_live;")
|
execute("DROP INDEX index_adverts_on_live;")
|
||||||
execute("DROP INDEX index_commissions_on_categories;")
|
execute("DROP INDEX index_commissions_on_categories;")
|
||||||
end
|
end
|
||||||
|
|
|
@ -46,7 +46,11 @@ defmodule Philomena.Repo.Migrations.ProdSchemaSync2 do
|
||||||
execute("ALTER SEQUENCE users_id_seq AS BIGINT;")
|
execute("ALTER SEQUENCE users_id_seq AS BIGINT;")
|
||||||
execute("ALTER SEQUENCE versions_id_seq AS BIGINT;")
|
execute("ALTER SEQUENCE versions_id_seq AS BIGINT;")
|
||||||
execute("CREATE INDEX index_users_on_created_at ON public.users USING btree (created_at);")
|
execute("CREATE INDEX index_users_on_created_at ON public.users USING btree (created_at);")
|
||||||
execute("CREATE INDEX index_users_on_role ON public.users USING btree (role) WHERE ((role)::text <> 'user'::text);")
|
|
||||||
|
execute(
|
||||||
|
"CREATE INDEX index_users_on_role ON public.users USING btree (role) WHERE ((role)::text <> 'user'::text);"
|
||||||
|
)
|
||||||
|
|
||||||
execute("DROP INDEX temp_unique_index_tags_on_name;")
|
execute("DROP INDEX temp_unique_index_tags_on_name;")
|
||||||
execute("DROP INDEX temp_unique_index_tags_on_slug;")
|
execute("DROP INDEX temp_unique_index_tags_on_slug;")
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue