Select the next project from the pool in round-robin order.
(self, token: Token, projects: List[Project])
| 189 | return project |
| 190 | |
| 191 | def _select_next_project(self, token: Token, projects: List[Project]) -> Project: |
| 192 | """Select the next project from the pool in round-robin order.""" |
| 193 | ordered_projects = self._sort_projects(projects) |
| 194 | if not ordered_projects: |
| 195 | raise ValueError("No available projects for token") |
| 196 | |
| 197 | if len(ordered_projects) == 1: |
| 198 | return ordered_projects[0] |
| 199 | |
| 200 | if token.current_project_id: |
| 201 | for index, project in enumerate(ordered_projects): |
| 202 | if project.project_id == token.current_project_id: |
| 203 | return ordered_projects[(index + 1) % len(ordered_projects)] |
| 204 | |
| 205 | return ordered_projects[0] |
| 206 | |
| 207 | # ========== Token CRUD ========== |
| 208 |
no test coverage detected