History module¶
Module for managing history
Route¶
- app.features.history.route.delete_history_item(body)¶
Delete entries from user history — tags:
features/history
- security:
BearerAuth: []
- requestBody:
required: true content:
- application/json:
- schema:
type: object required: [ids] properties:
- ids:
type: array description: IDs to delete items:
type: integer
example: [7, 8, 3]
- responses:
- 200:
description: Successful deletion content:
- application/json:
- schema:
type: object required: [data, error] properties:
- data:
type: object nullable: true example: null
- error:
type: string nullable: true example: null
- 400:
description: Validation error of incoming JSON (Pydantic) content:
- application/json:
- schema:
type: object properties:
- validation_error:
type: object properties:
- body_params:
type: array items:
type: object properties:
- input:
type: string example: “jhgjk”
- loc:
type: array items:
type: string
example: [“ids”, 0]
- msg:
type: string example: “Input should be a valid integer…”
- type:
type: string example: “int_parsing”
- url:
type: string example: “https://pydantic.dev…”
- 401:
description: Unauthorized (missing or invalid JWT) content:
- application/json:
- schema:
type: object properties:
- message:
type: string example: “Missing Authorization Header”
- 409:
description: Server error / Business error content:
- application/json:
- schema:
type: object required: [data, error] properties:
- data:
type: object nullable: true example: null
- error:
type: string example: “Database error”
- Parameters:
body (DeleteHistoryRequest)
- app.features.history.route.get_history_route()¶
Get user history — tags:
features/history
- security:
BearerAuth: []
- responses:
- 200:
description: Successful retrieval of history content:
- application/json:
- schema:
type: object required: [data, error] properties:
- data:
type: array items:
type: object required: [id, word] properties:
- id:
type: integer example: 7
- word:
type: string example: “meet”
- error:
type: string nullable: true example: null
- 401:
description: Unauthorized (missing or invalid JWT) content:
- application/json:
- schema:
type: object properties:
- message:
type: string example: “Missing Authorization Header”
- 409:
description: Server error / Business error content:
- application/json:
- schema:
type: object required: [data, error] properties:
- data:
type: object nullable: true example: null
- error:
type: string example: “Database error”
Service¶
- class app.features.history.service.HistoryService¶
Bases:
objectService for managing user translation history data.
- delete_history(ids, user_id)¶
Deletes specific items from a user’s translation history.
- Parameters:
ids (list[int]) – A list of history entry IDs to be deleted.
user_id (int) – The unique ID of the user.
- Returns:
The data transfer object containing the operation results.
- Return type:
BaseDTO[None]
- get_history(user_id)¶
Retrieves the translation history for a specific user.
- Parameters:
user_id (int) – The unique ID of the user.
- Returns:
The data transfer object containing the list of translation history entries.
- Return type:
BaseDTO[list[TranslationDTO]]
- is_user_owns_history_item(user_id, translation_id)¶
Checks if a specific history element belongs to a given user.
- Parameters:
user_id (int) – The unique ID of the user.
translation_id (int) – The unique ID of the translation entry.
- Returns:
True if the user owns the history element, False otherwise.
- Return type:
bool
Repository¶
- class app.features.history.repository.HistoryRepository¶
Bases:
objectRepository for managing user translation history records in the database.
- delete_history_item(id)¶
Deletes a specific element from the user’s translation history.
- Parameters:
id (int) – The unique ID of the element to delete.
- get_history(user_id)¶
Retrieves the translation history for a specific user.
- Parameters:
user_id (int) – The unique ID of the user.
- Returns:
A list of translation history elements.
- Return type:
list[Translation]
- get_history_item(translation_id)¶
Retrieves a specific translation history element by its ID.
- Parameters:
translation_id (int) – The unique ID of the translation element.
- Returns:
The requested translation history element.
- Return type:
Requests¶
Responses¶
- class app.features.history.responses.HistoryItem¶
Bases:
BaseModelRepresents an individual entry within the translation history log.
- id: int¶
The unique ID of the history item.
- word: str¶
The word that was translated and saved.
- app.features.history.responses.HistoryResponse¶
Type alias for the API response containing a list of history items.
Fields¶ Field
Type
Required
Default
dataList[HistoryItem] |NoneNo
Noneerrorstr|NoneNo
None