quivr/backend/modules/onboarding/service/onboarding_service.py
Zineb El Bachiri 0782df5e37
refactor: Notification module (#1740)
# Description

- Notification module

## Checklist before requesting a review

Please delete options that are not relevant.

- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my code
- [ ] I have commented hard-to-understand areas
- [ ] I have ideally added tests that prove my fix is effective or that
my feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged

## Screenshots (if appropriate):
2023-11-28 14:27:39 +01:00

50 lines
1.6 KiB
Python

from uuid import UUID
from modules.onboarding.dto.inputs import OnboardingUpdatableProperties
from modules.onboarding.entity.onboarding import OnboardingStates
from modules.onboarding.repository.onboardings import Onboarding
from modules.onboarding.repository.onboardings_interface import OnboardingInterface
class OnboardingService:
repository: OnboardingInterface
def __init__(self):
self.repository = Onboarding()
def create_user_onboarding(self, user_id: UUID) -> OnboardingStates:
"""Update user onboarding information by user_id"""
return self.repository.create_user_onboarding(user_id)
def get_user_onboarding(self, user_id: UUID) -> OnboardingStates | None:
"""
Get a user's onboarding status
Args:
user_id (UUID): The id of the user
Returns:
Onboardings: The user's onboarding status
"""
return self.repository.get_user_onboarding(user_id)
def remove_onboarding_more_than_x_days(self, days: int):
"""
Remove onboarding if it is older than x days
"""
self.repository.remove_onboarding_more_than_x_days(days)
def update_user_onboarding(
self, user_id: UUID, onboarding: OnboardingUpdatableProperties
) -> OnboardingStates:
"""Update user onboarding information by user_id"""
updated_onboarding = self.repository.update_user_onboarding(user_id, onboarding)
if all(not value for value in updated_onboarding.dict().values()):
self.repository.remove_user_onboarding(user_id)
return updated_onboarding