mirror of
https://github.com/QuivrHQ/quivr.git
synced 2024-12-18 11:51:41 +03:00
0782df5e37
# 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):
50 lines
1.6 KiB
Python
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
|