-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f9b921b
commit 7b7fb92
Showing
4 changed files
with
86 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from app.repository.user_points_repository import UserPointsRepository | ||
|
||
|
||
def get_user_measurements_count( | ||
user_id: int, | ||
user_points_repository: UserPointsRepository) -> int: | ||
""" | ||
Get the number of measurements a user has completed in a campaign. | ||
Args: | ||
user_id (int): The user's unique identifier. | ||
user_points_repository (UserPointsRepository): The repository to access user points data. | ||
Returns: | ||
int: The number of measurements completed by the user. | ||
""" | ||
# Asumiendo que UserPointsRepository tiene un método para contar mediciones por user_id | ||
measurements_count = user_points_repository.count_measurements_by_user_id( | ||
user_id) | ||
|
||
return measurements_count |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
from app.repository.base_repository import BaseRepository | ||
from contextlib import AbstractContextManager | ||
from typing import Callable | ||
|
||
from sqlalchemy.orm import Session | ||
|
||
from app.repository.game_params_repository import GameParamsRepository | ||
from app.repository.game_repository import GameRepository | ||
from app.repository.strategy_repository import StrategyRepository | ||
from app.repository.task_repository import TaskRepository | ||
from app.repository.user_points_repository import UserPointsRepository | ||
from app.repository.user_repository import UserRepository | ||
from app.repository.wallet_repository import WalletRepository | ||
from app.repository.wallet_transaction_repository import WalletTransactionRepository | ||
|
||
|
||
class EngineRepository(BaseRepository): | ||
|
||
def __init__( | ||
self, | ||
session_factory: Callable[..., AbstractContextManager[Session]], | ||
model_game_params_repository=GameParamsRepository, | ||
model_game_repository=GameRepository, | ||
model_strategy_repository=StrategyRepository, | ||
model_task_repository=TaskRepository, | ||
model_user_points_repository=UserPointsRepository, | ||
model_user_repository=UserRepository, | ||
model_wallet_repository=WalletRepository, | ||
model_wallet_transaction_repository=WalletTransactionRepository | ||
) -> None: | ||
self.model_game_params_repository = model_game_params_repository | ||
self.model_game_repository = model_game_repository | ||
self.model_strategy_repository = model_strategy_repository | ||
self.model_task_repository = model_task_repository | ||
self.model_user_points_repository = model_user_points_repository | ||
self.model_user_repository = model_user_repository | ||
self.model_wallet_repository = model_wallet_repository | ||
self.model_wallet_transaction_repository = model_wallet_transaction_repository | ||
super().__init__( | ||
session_factory, | ||
model_game_params_repository, | ||
model_game_repository, | ||
model_strategy_repository, | ||
model_task_repository, | ||
model_user_points_repository, | ||
model_user_repository, | ||
model_wallet_repository, | ||
model_wallet_transaction_repository | ||
) |