Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: advanced filters for feedbacks and chats admin api #525

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

sszgwdk
Copy link
Collaborator

@sszgwdk sszgwdk commented Dec 20, 2024

part of #389

Copy link

vercel bot commented Dec 20, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
tidb-ai-preview ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 31, 2024 6:31am
tidb-ai-storybook ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 31, 2024 6:31am

Copy link

vercel bot commented Dec 20, 2024

@sszgwdk is attempting to deploy a commit to the pingcap Team on Vercel.

A member of the Team first needs to authorize it.

router = APIRouter()


@router.get("/users")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This API is used only for admin users.

Move to /api/v1/admin/stats/chats/users

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think /api/v1/admin/users is reasonable, the API is design for filter option list.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do I need to roll back the code?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Mini256 Only rollback this API is ok to me, this is the standard get users list api. The rest are stats api.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

class ChatOrigin(UUIDBaseModel):
origin: str

@router.get("/chats/origins")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This API is used only for admin users.

Move to /api/v1/admin/stats/chats/origins

params=params,
)

@router.get("/admin/feedbacks/origins")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move to /api/v1/admin/stats/feedbacks/origins

@634750802 634750802 changed the title Advanced filters for feedbacks and chats admin API feat: advanced filters for feedbacks and chats admin api Dec 24, 2024
@634750802 634750802 self-requested a review December 27, 2024 02:36
) -> Page[ChatOrigin]:
return paginate(
session,
select(Chat.origin, Chat.id).order_by(Chat.created_at.desc()),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we only need to return distinct Chat.origin values

) -> Page[User]:
return paginate(
session,
select(User).order_by(User.id),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about:

  • /admin/users -> /admin/users/search
  • list_users -> search_users

Maybe we need a search parameter for user search. The user list may be very long, and we need to consider how to help users find the user_id they need.

For the return type, you can using UserDescriptor instead to avoid return unnecessary or sensitive information to the frontend.

Add email: str to UserDescriptor:

https://github.com/pingcap/autoflow/blob/9b05f1016c0df9b6bca18ba7ad01c3b7579bab64/backend/app/api/admin_routes/models.py#L21C7-L21C21

user: CurrentSuperuserDep,
params: Params = Depends(),
) -> Page[ChatOrigin]:
return paginate(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, I perfer to using ChatRepo to handle all of DB access operaction of Chat model, so that we can reuse it in other place.

class ChatOrigin(UUIDBaseModel):
origin: str

@router.get("/admin/stats/chats/origins")
Copy link
Member

@Mini256 Mini256 Dec 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the route path naming, you can share your points on the two naming methods /admin/stats/chats/origins vs /admin/chats/origins

design first, then code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants