ragflow icon indicating copy to clipboard operation
ragflow copied to clipboard

[Question]: I can't understand meaning of `tenants = UserTenantService.query(user_id=current_user.id)`

Open zombieyang opened this issue 10 months ago • 3 comments

Describe your problem

There are many places will query tenant by this way Image

However, when I review the invite logic, I realized that it is querying the first tenant that the user has joined. Image

The question is, why should we check the "first" tenant that the user has joined? I think it is not stable to depend on the order.

zombieyang avatar Mar 03 '25 02:03 zombieyang

For now, there's only one tenant will be returned.

KevinHuSh avatar Mar 03 '25 05:03 KevinHuSh

I'm still in 0.16.0, In my test, it returned 3 tenant after I joined 2 other teams.

Image

should it be changed to tenants = UserTenantService.query(user_id=current_user.id, role=UserTenantRole.OWNER)?

I can make a PR.

zombieyang avatar Mar 03 '25 08:03 zombieyang

Actually in my case, I forcely add a default UserTenant during registration, so when ragflow query the first one (It may sorted by time? idk), it broke.

I think it just not robust to depend on the returning order.

zombieyang avatar Mar 03 '25 09:03 zombieyang