repository.transform#

Module Contents#

Classes#

TransformRepository

Class for interacting with the database and services for storing and transforming images.

API#

class repository.transform.TransformRepository(session: sqlalchemy.ext.asyncio.AsyncSession)#

Class for interacting with the database and services for storing and transforming images.

Parameters:

session (AsyncSession) – Asynchronous SQLAlchemy session object for database interaction.

Initialization

async create_transformed_picture(user_id: int, original_picture_id: int, transformation_params: dict)#

Creates a new transformed picture entry in the database.

Parameters:
  • user_id (int) – User ID associated with the transformed picture.

  • original_picture_id (int) – ID of the original picture to be transformed.

  • transformation_params (dict) – Dictionary containing transformation parameters.

Returns:

The created TransformedPicture object or None if an exception occurs.

Return type:

TransformedPicture or None

async update_transformed_picture(transformed_picture_id: int, transformation_params: dict)#

Updates an existing transformed picture entry in the database.

Parameters:
  • transformed_picture_id (int) – ID of the transformed picture to be updated.

  • transformation_params (dict) – Dictionary containing transformation parameters.

Returns:

The updated TransformedPicture object or None if an exception occurs.

Return type:

TransformedPicture or None

async get_picture_by_id(picture_id: int)#

Retrieves a Picture object from the database based on its ID.

Parameters:

picture_id (int) – ID of the picture to be retrieved.

Returns:

The retrieved Picture object or None if not found.

Return type:

Picture or None

async get_transformed_picture(transformed_picture_id: int)#

Retrieves a TransformedPicture object from the database based on its ID.

Parameters:

transformed_picture_id (int) – ID of the transformed picture to be retrieved.

Returns:

The retrieved TransformedPicture object or None if not found.

Return type:

TransformedPicture or None

async get_user_transforms(user_id: int)#

Retrieves a list of transformed pictures associated with a specific user.

Parameters:

user_id (int) – User ID for which transformed pictures are to be retrieved.

Returns:

List of TransformedPicture objects associated with the user.

Return type:

list[TransformedPicture]

async delete_transformed_picture(transformed_picture_id: int)#

Deletes a transformed picture entry from the database.

Parameters:

transformed_picture_id (int) – ID of the transformed picture to be deleted.

Returns:

True if the deletion is successful, False otherwise.

Return type:

bool

Raises:

HTTPException – If there is an issue with cloud service operations or a server error occurs.