Refine Autonomous Mode Caching Logic in ListRobots API
- Updated the ListRobots function to enhance caching behavior by explicitly requiring the autonomous_mode filter to be true when using cached results. - Improved comments for clarity on caching conditions and the implications of autonomous_mode filtering. - Ensured that when autonomous_mode is not specified or set to false, the database is queried to include all robots, maintaining comprehensive results.
This commit is contained in:
parent
ff412da7b3
commit
c63c68fd7b
1 changed files with 5 additions and 3 deletions
|
|
@ -62,9 +62,11 @@ func ListRobots(ctx *types.Context, query *ListQuery) (*ListResult, error) {
|
|||
return listRobotsFromDB(query)
|
||||
}
|
||||
|
||||
// If only teamID specified (no other filters), use cache for faster lookup
|
||||
// Note: Cache only contains autonomous_mode=true robots, so this is safe
|
||||
if query.TeamID != "" && query.Status == "" && query.Keywords == "" && query.ClockMode == "" {
|
||||
// If only teamID specified AND explicitly filtering for autonomous_mode=true, use cache
|
||||
// Cache only contains autonomous_mode=true robots
|
||||
// When autonomous_mode is not specified or false, must query database to include all robots
|
||||
if query.TeamID != "" && query.Status == "" && query.Keywords == "" && query.ClockMode == "" &&
|
||||
query.AutonomousMode != nil && *query.AutonomousMode == true {
|
||||
robots := mgr.Cache().List(query.TeamID)
|
||||
return paginateRobots(robots, query), nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue