Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
liamwhite committed Jul 28, 2024
2 parents 600341a + 5636077 commit e5fe3ce
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 4 deletions.
1 change: 1 addition & 0 deletions index/images.mk
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ metadata: image_search_json
'processed', processed,
'score', score,
'size', image_size,
'orig_size', image_orig_size,
'sha512_hash', image_sha512_hash,
'thumbnails_generated', thumbnails_generated,
'updated_at', updated_at,
Expand Down
3 changes: 3 additions & 0 deletions lib/philomena/images/image.ex
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ defmodule Philomena.Images.Image do
field :image_width, :integer
field :image_height, :integer
field :image_size, :integer
field :image_orig_size, :integer
field :image_format, :string
field :image_mime_type, :string
field :image_aspect_ratio, :float
Expand Down Expand Up @@ -137,6 +138,7 @@ defmodule Philomena.Images.Image do
:image_width,
:image_height,
:image_size,
:image_orig_size,
:image_format,
:image_mime_type,
:image_aspect_ratio,
Expand All @@ -152,6 +154,7 @@ defmodule Philomena.Images.Image do
:image_width,
:image_height,
:image_size,
:image_orig_size,
:image_format,
:image_mime_type,
:image_aspect_ratio,
Expand Down
2 changes: 1 addition & 1 deletion lib/philomena/images/query.ex
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ defmodule Philomena.Images.Query do
defp anonymous_fields do
[
int_fields:
~W(id width height score upvotes downvotes faves uploader_id faved_by_id pixels size comment_count source_count tag_count) ++
~W(id width height score upvotes downvotes faves uploader_id faved_by_id pixels size orig_size comment_count source_count tag_count) ++
tag_count_fields(),
float_fields: ~W(aspect_ratio wilson_score duration),
date_fields: ~W(created_at updated_at first_seen_at),
Expand Down
2 changes: 2 additions & 0 deletions lib/philomena/images/search_index.ex
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ defmodule Philomena.Images.SearchIndex do
processed: %{type: "boolean"},
score: %{type: "integer"},
size: %{type: "integer"},
orig_size: %{type: "integer"},
sha512_hash: %{type: "keyword"},
source_url: %{type: "keyword"},
source_count: %{type: "integer"},
Expand Down Expand Up @@ -117,6 +118,7 @@ defmodule Philomena.Images.SearchIndex do
height: image.image_height,
pixels: image.image_width * image.image_height,
size: image.image_size,
orig_size: image.image_orig_size,
animated: image.image_is_animated,
duration: if(image.image_is_animated, do: image.image_duration, else: 0),
tag_count: length(image.tags),
Expand Down
3 changes: 3 additions & 0 deletions lib/philomena_media/uploader.ex
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ defmodule PhilomenaMedia.Uploader do
* `width` (integer) - the width of the file
* `height` (integer) - the height of the file
* `size` (integer) - the size of the file, in bytes
* `orig_size` (integer) - the size of the file, in bytes
* `format` (String) - the file extension, one of `~w(gif jpg png svg webm)`, determined by reading the file
* `mime_type` (String) - the file's sniffed MIME type, determined by reading the file
* `duration` (float) - the duration of the media file
Expand All @@ -148,6 +149,7 @@ defmodule PhilomenaMedia.Uploader do
:foo_width,
:foo_height,
:foo_size,
:foo_orig_size,
:foo_format,
:foo_mime_type,
:foo_duration,
Expand Down Expand Up @@ -221,6 +223,7 @@ defmodule PhilomenaMedia.Uploader do
"width" => analysis.width,
"height" => analysis.height,
"size" => analysis.size,
"orig_size" => analysis.size,
"format" => analysis.extension,
"mime_type" => analysis.mime_type,
"duration" => analysis.duration,
Expand Down
1 change: 1 addition & 0 deletions lib/philomena_web/views/api/json/image_view.ex
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ defmodule PhilomenaWeb.Api.Json.ImageView do
height: image.image_height,
mime_type: image.image_mime_type,
size: image.image_size,
orig_size: image.image_orig_size,
duration: image.image_duration,
animated: image.image_is_animated,
format: image.image_format,
Expand Down
9 changes: 9 additions & 0 deletions priv/repo/migrations/20240723122759_add_images_orig_size.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
defmodule Philomena.Repo.Migrations.AddImagesOrigSize do
use Ecto.Migration

def change do
alter table("images") do
add :image_orig_size, :integer
end
end
end
11 changes: 8 additions & 3 deletions priv/repo/structure.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
-- PostgreSQL database dump
--

-- Dumped from database version 15.2
-- Dumped by pg_dump version 15.2
-- Dumped from database version 16.3
-- Dumped by pg_dump version 16.3

SET statement_timeout = 0;
SET lock_timeout = 0;
Expand Down Expand Up @@ -1051,7 +1051,8 @@ CREATE TABLE public.images (
image_duration double precision,
description character varying DEFAULT ''::character varying NOT NULL,
scratchpad character varying,
approved boolean DEFAULT false
approved boolean DEFAULT false,
image_orig_size integer
);


Expand Down Expand Up @@ -5171,6 +5172,9 @@ ALTER TABLE ONLY public.image_tag_locks

ALTER TABLE ONLY public.moderation_logs
ADD CONSTRAINT moderation_logs_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;


--
-- Name: source_changes source_changes_image_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

Expand Down Expand Up @@ -5228,3 +5232,4 @@ INSERT INTO public."schema_migrations" (version) VALUES (20211219194836);
INSERT INTO public."schema_migrations" (version) VALUES (20220321173359);
INSERT INTO public."schema_migrations" (version) VALUES (20230330155026);
INSERT INTO public."schema_migrations" (version) VALUES (20230402170921);
INSERT INTO public."schema_migrations" (version) VALUES (20240723122759);

0 comments on commit e5fe3ce

Please sign in to comment.