Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add thumbnail support #3

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Add thumbnail support #3

wants to merge 1 commit into from

Conversation

kheina
Copy link
Contributor

@kheina kheina commented Jan 14, 2025

No description provided.

Copy link

github-actions bot commented Jan 14, 2025

PR Summary

This PR adds thumbnail support to the database and image uploader. It modifies various database schemas, models, and repositories to accommodate thumbnail storage and retrieval. The changes include adding a thumbnails table, updating the posts table to include a thumbhash column, and modifying views and functions to handle thumbnails. The docker image for the database is also updated.

Changes

File Summary
db/00/00-init.sql Modified the add_tags procedure and other functions to use the public schema consistently. Removed unnecessary newlines and improved formatting.
db/07/01-post_media.sql Updated the internal_posts view and internal_posts_funcs function to use the public schema consistently.
db/07/02-immutable-cols.sql Added a begin; and commit; statement to ensure the transaction is properly handled. Updated schema to public.
db/07/03-drop-post-media-cols.sql Updated the immutable_columns trigger to use the public schema consistently.
db/08/00-post-immutable-cols.sql Updated the immutable_columns trigger to use the public schema consistently.
db/09/01-add-media-thumbnails.sql Added a thumbnails table to store thumbnail information. Created a view collated_thumbnails to aggregate thumbnail data. Updated the internal_posts view and function to include thumbnails.
docker-compose.yml Updated the database image from postgres:13-alpine to postgres:17-alpine.
emojis/emoji.py Reordered imports to improve readability and maintainability.
emojis/repository.py Reordered imports and added explicit type annotations for better code clarity.
emojis/router.py Added an empty line for better readability.
init.py Updated the uploadEmojis function to include a progress bar and handle potential errors more gracefully. Modified the readSecret function to handle nested secrets more robustly.
posts/models.py Added a Thumbnail model to represent thumbnail data. Updated the Media model to include a list of Thumbnail objects. Added type annotations and improved validation.
posts/posts.py Modified queries to use fetch_one = True for improved efficiency. Updated queries to use the public schema consistently. Added a join to the thumbnails table in several queries.
posts/repository.py Updated the RatingMap class to use fetch_one = True for improved efficiency. Added a get_id method to the RatingMap class. Updated the Posts class to handle thumbnails in the database response. Updated type annotations and improved validation.
posts/router.py Updated the v1Post function to use the response_model parameter for improved type hinting.
posts/uploader.py Added resource limits for memory, map, and disk. Added functions to upload and insert thumbnails. Updated the uploadImage function to handle thumbnails and potential errors more gracefully. Improved error handling and logging.
sets/repository.py Updated the authorized function to use the get_id method of the privacy_map for improved consistency.
sets/sets.py Updated the _validate_privacy function to use the get_id method of the privacy_map for improved consistency. Updated the get_post_sets function to handle thumbnails in the database response.
shared/auth/__init__.py Removed an unnecessary empty line.
shared/logging.py Improved colorization of log messages for better readability. Updated color scheme for better contrast.
shared/maps.py Added a get_id method to the PrivacyMap class for improved consistency.
shared/models/_shared.py Added a PostIdValidator to validate post_id values. Added type annotations and improved validation.
shared/sql/query.py Added support for CTEs (Common Table Expressions) in the Query class. Added support for aliases in the Field class. Improved type annotations and error handling.
shared/utilities/json.py Updated the json_stream function to handle boolean values correctly. Improved type annotations and error handling.
tags/models.py Removed unnecessary imports.
tags/repository.py Added a portable method to convert Tag objects to TagPortable objects. Added a tags method to fetch and convert InternalTag objects to Tag objects. Added a groups method to group tags by group name. Updated type annotations and improved validation.
tags/tagger.py Updated the addTags and removeTags functions to use the get_id method of the privacy_map for improved consistency. Updated type annotations and improved validation.

autogenerated by presubmit.ai

@github-actions github-actions bot changed the title Storing Thumbnails in DB @presubmit Add thumbnail support Jan 14, 2025
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Review Summary

Commits Considered (1)
Files Processed (29)
  • db/00/00-init.sql (32 hunks)
  • db/07/01-post_media.sql (3 hunks)
  • db/07/02-immutable-cols.sql (2 hunks)
  • db/07/03-drop-post-media-cols.sql (1 hunk)
  • db/08/00-post-immutable-cols.sql (1 hunk)
  • db/09/01-add-media-thumbnails.sql (1 hunk)
  • docker-compose.yml (1 hunk)
  • emojis/emoji.py (1 hunk)
  • emojis/repository.py (1 hunk)
  • emojis/router.py (1 hunk)
  • init.py (5 hunks)
  • posts/models.py (11 hunks)
  • posts/posts.py (18 hunks)
  • posts/repository.py (18 hunks)
  • posts/router.py (1 hunk)
  • posts/uploader.py (17 hunks)
  • sets/repository.py (1 hunk)
  • sets/sets.py (6 hunks)
  • shared/auth/init.py (1 hunk)
  • shared/logging.py (5 hunks)
  • shared/maps.py (1 hunk)
  • shared/models/_shared.py (1 hunk)
  • shared/sql/query.py (11 hunks)
  • shared/utilities/json.py (1 hunk)
  • tags/models.py (1 hunk)
  • tags/repository.py (2 hunks)
  • tags/tagger.py (7 hunks)
  • users/repository.py (1 hunk)
  • users/users.py (1 hunk)
Actionable Comments (0)
Skipped Comments (0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant