mirror of
https://github.com/QuivrHQ/quivr.git
synced 2024-12-14 17:03:29 +03:00
feat: update onboarding controller and fix typo (#1333)
<img width="525" alt="Screenshot 2023-10-05 at 10 55 29" src="https://github.com/StanGirard/quivr/assets/63923024/d7a4e7ef-e73f-46d0-8499-06c5e951f64a"> <img width="1207" alt="Screenshot 2023-10-05 at 10 49 45" src="https://github.com/StanGirard/quivr/assets/63923024/50eba38a-b2cb-4e7d-82b1-ceca60abdad4"> https://github.com/StanGirard/quivr/issues/1328
This commit is contained in:
parent
64315d05da
commit
28ef515458
@ -21,6 +21,7 @@ from routes.explore_routes import explore_router
|
||||
from routes.knowledge_routes import knowledge_router
|
||||
from routes.misc_routes import misc_router
|
||||
from routes.notification_routes import notification_router
|
||||
from routes.onboarding_routes import onboarding_router
|
||||
from routes.prompt_routes import prompt_router
|
||||
from routes.subscription_routes import subscription_router
|
||||
from routes.upload_routes import upload_router
|
||||
@ -49,8 +50,10 @@ async def startup_event():
|
||||
app.include_router(brain_router)
|
||||
app.include_router(chat_router)
|
||||
app.include_router(crawl_router)
|
||||
app.include_router(onboarding_router)
|
||||
app.include_router(explore_router)
|
||||
app.include_router(misc_router)
|
||||
|
||||
app.include_router(upload_router)
|
||||
app.include_router(user_router)
|
||||
app.include_router(api_key_router)
|
||||
|
@ -5,11 +5,11 @@ from fastapi import HTTPException
|
||||
from models.databases.repository import (
|
||||
Repository, # Assuming you have a repository class
|
||||
)
|
||||
from models.onboarding import Onboardings
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class OnboardingUpdatableProperties(BaseModel):
|
||||
|
||||
"""Properties that can be received on onboarding update"""
|
||||
|
||||
onboarding_b1: Optional[bool]
|
||||
@ -17,11 +17,19 @@ class OnboardingUpdatableProperties(BaseModel):
|
||||
onboarding_b3: Optional[bool]
|
||||
|
||||
|
||||
class GetOnboardingResponse(BaseModel):
|
||||
"""Response when getting onboarding"""
|
||||
|
||||
onboarding_b1: bool
|
||||
onboarding_b2: bool
|
||||
onboarding_b3: bool
|
||||
|
||||
|
||||
class Onboarding(Repository):
|
||||
def __init__(self, supabase_client):
|
||||
self.db = supabase_client
|
||||
|
||||
def get_user_onboarding(self, user_id: UUID) -> Onboardings:
|
||||
def get_user_onboarding(self, user_id: UUID) -> GetOnboardingResponse | None:
|
||||
"""
|
||||
Get user onboarding information by user_id
|
||||
"""
|
||||
@ -33,30 +41,24 @@ class Onboarding(Repository):
|
||||
.execute()
|
||||
).data
|
||||
|
||||
if not onboarding_data:
|
||||
raise HTTPException(404, "User onboarding not found")
|
||||
if onboarding_data == []:
|
||||
return None
|
||||
|
||||
return Onboardings(**onboarding_data[0])
|
||||
return GetOnboardingResponse(**onboarding_data[0])
|
||||
|
||||
def update_user_onboarding(
|
||||
self, user_id: UUID, onboarding: OnboardingUpdatableProperties
|
||||
) -> Onboardings:
|
||||
) -> GetOnboardingResponse:
|
||||
"""Update user onboarding information by user_id"""
|
||||
response = (
|
||||
self.db.from_("onboarding")
|
||||
.upsert(
|
||||
{
|
||||
"user_id": user_id,
|
||||
"onboarding_b1": onboarding.onboarding_b1,
|
||||
"onboarding_b2": onboarding.onboarding_b2,
|
||||
"onboarding_b3": onboarding.onboarding_b3,
|
||||
},
|
||||
unique_keys=["user_id"],
|
||||
)
|
||||
.update(onboarding.dict())
|
||||
.match({"user_id": user_id})
|
||||
.execute()
|
||||
.data
|
||||
)
|
||||
|
||||
if not response:
|
||||
raise HTTPException(404, "User onboarding not updated")
|
||||
return Onboardings(**response[0])
|
||||
|
||||
return GetOnboardingResponse(**response[0])
|
||||
|
@ -1,10 +1,8 @@
|
||||
from dataclasses import dataclass
|
||||
from uuid import UUID
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
@dataclass
|
||||
class Onboardings(BaseModel):
|
||||
user_id: UUID
|
||||
onboarding_b1: bool
|
||||
|
@ -1,10 +1,10 @@
|
||||
from uuid import UUID
|
||||
|
||||
from models.onboarding import Onboardings
|
||||
from models.databases.supabase.onboarding import GetOnboardingResponse
|
||||
from models.settings import get_supabase_db
|
||||
|
||||
|
||||
def get_user_onboarding(user_id: UUID) -> Onboardings:
|
||||
def get_user_onboarding(user_id: UUID) -> GetOnboardingResponse | None:
|
||||
"""
|
||||
Get a user's onboarding status
|
||||
|
||||
|
@ -1,13 +1,15 @@
|
||||
from uuid import UUID
|
||||
|
||||
from models.databases.supabase.onboarding import OnboardingUpdatableProperties
|
||||
from models.onboarding import Onboardings
|
||||
from models.databases.supabase.onboarding import (
|
||||
GetOnboardingResponse,
|
||||
OnboardingUpdatableProperties,
|
||||
)
|
||||
from models.settings import get_supabase_db
|
||||
|
||||
|
||||
def update_user_onboarding(
|
||||
user_id: UUID, onboarding: OnboardingUpdatableProperties
|
||||
) -> Onboardings:
|
||||
) -> GetOnboardingResponse:
|
||||
"""Update user onboarding information by user_id"""
|
||||
|
||||
supabase_db = get_supabase_db()
|
||||
|
@ -3,7 +3,10 @@ from auth import (
|
||||
get_current_user, # Assuming you have a get_current_user function
|
||||
)
|
||||
from fastapi import APIRouter, Depends
|
||||
from models.databases.supabase.onboarding import OnboardingUpdatableProperties
|
||||
from models.databases.supabase.onboarding import (
|
||||
GetOnboardingResponse,
|
||||
OnboardingUpdatableProperties,
|
||||
)
|
||||
from models.user_identity import UserIdentity
|
||||
from repository.onboarding.get_user_onboarding import get_user_onboarding
|
||||
from repository.onboarding.udpate_user_onboarding import update_user_onboarding
|
||||
@ -18,7 +21,7 @@ onboarding_router = APIRouter()
|
||||
)
|
||||
async def get_user_onboarding_handler(
|
||||
current_user: UserIdentity = Depends(get_current_user),
|
||||
):
|
||||
) -> GetOnboardingResponse | None:
|
||||
"""
|
||||
Get user onboarding information for the current user
|
||||
"""
|
||||
@ -34,7 +37,7 @@ async def get_user_onboarding_handler(
|
||||
async def update_user_onboarding_handler(
|
||||
onboarding: OnboardingUpdatableProperties,
|
||||
current_user: UserIdentity = Depends(get_current_user),
|
||||
):
|
||||
) -> GetOnboardingResponse:
|
||||
"""
|
||||
Update user onboarding information for the current user
|
||||
"""
|
||||
|
@ -40,7 +40,7 @@
|
||||
"download_message_2": "Step 1: Download “Quivr documentation”",
|
||||
"upload_message_1": "Congratulations on your first step 🥳",
|
||||
"upload_message_2": "Step 2: Now Drag and drop it on the chat or in the 📎",
|
||||
"how_to_use_quivr": "How to user Quivr",
|
||||
"how_to_use_quivr": "How to use Quivr ?",
|
||||
"what_is_quivr": "What is Quivr ?",
|
||||
"what_is_brain": "What is a brain ?",
|
||||
"last_step": "Last step 🥳",
|
||||
|
@ -40,7 +40,7 @@
|
||||
"download_message_2": "Paso 1: Descargar la documentación de “Quivr”",
|
||||
"upload_message_1": "¡Felicidades por tu primer paso 🥳!",
|
||||
"upload_message_2": "Paso 2: Ahora, arrástralo y suéltalo en el chat o en el 📎",
|
||||
"how_to_use_quivr": "Cómo usar Quivr",
|
||||
"how_to_use_quivr": "¿Cómo usar Quivr?",
|
||||
"what_is_quivr": "¿Qué es Quivr?",
|
||||
"what_is_brain": "¿Qué es un cerebro?",
|
||||
"last_step":"Último paso 🥳",
|
||||
|
@ -40,7 +40,7 @@
|
||||
"download_message_2": "Étape 1 : Téléchargez la documentation de “Quivr”",
|
||||
"upload_message_1": "Félicitations pour votre première étape 🥳!",
|
||||
"upload_message_2": "Étape 2 : Maintenant, faites glisser et déposez-le dans le chat ou dans 📎",
|
||||
"how_to_use_quivr": "Comment utiliser Quivr",
|
||||
"how_to_use_quivr": "Comment utiliser Quivr ?",
|
||||
"what_is_quivr": "Qu'est-ce que Quivr ?",
|
||||
"what_is_brain": "Qu'est-ce qu'un cerveau ?",
|
||||
"last_step":"Dernière étape 🥳",
|
||||
|
@ -40,7 +40,7 @@
|
||||
"download_message_2": "Passo 1: Baixe a documentação do 'Quivr'",
|
||||
"upload_message_1": "Parabéns pelo seu primeiro passo 🥳!",
|
||||
"upload_message_2": "Passo 2: Agora, arraste e solte no chat ou na 📎",
|
||||
"how_to_use_quivr": "Como usar o Quivr",
|
||||
"how_to_use_quivr": "Como usar o Quivr?",
|
||||
"what_is_quivr": "O que é o Quivr?",
|
||||
"what_is_brain": "O que é um cérebro?",
|
||||
"last_step":"Dernière étape 🥳",
|
||||
|
@ -40,7 +40,7 @@
|
||||
"download_message_2": "Шаг 1: Скачайте документацию Quivr",
|
||||
"upload_message_1": "Поздравляем с первым шагом 🥳!",
|
||||
"upload_message_2": "Шаг 2: Теперь перетащите его в чат или в 📎",
|
||||
"how_to_use_quivr": "Как использовать Quivr",
|
||||
"how_to_use_quivr": "Как использовать Quivr?",
|
||||
"what_is_quivr": "Что такое Quivr?",
|
||||
"what_is_brain": "Что такое мозг?",
|
||||
"last_step":"Последний шаг 🥳",
|
||||
|
@ -41,7 +41,7 @@
|
||||
"download_message_2": "步骤 1:下载“Quivr 文档”",
|
||||
"upload_message_1": "恭喜您迈出第一步 🥳!",
|
||||
"upload_message_2": "第2步:现在,将其拖放到聊天框或 📎 中",
|
||||
"how_to_use_quivr": "如何使用Quivr",
|
||||
"how_to_use_quivr": "如何使用Quivr?",
|
||||
"what_is_quivr": "什么是Quivr?",
|
||||
"what_is_brain": "什么是大脑?",
|
||||
"last_step":"最后一步 🥳",
|
||||
|
Loading…
Reference in New Issue
Block a user