mirror of
https://github.com/dkmstr/openuds.git
synced 2025-03-28 10:50:25 +03:00
fixed MetaPool orderer
This commit is contained in:
parent
84ca0b2e41
commit
9a7afe7839
@ -33,6 +33,7 @@
|
||||
import logging
|
||||
import random
|
||||
import typing
|
||||
from uds.models.meta_pool import MetaPoolMember
|
||||
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.db.models import Q
|
||||
@ -656,14 +657,14 @@ class UserServiceManager:
|
||||
if meta.isAccessAllowed() is False:
|
||||
raise ServiceAccessDeniedByCalendar()
|
||||
|
||||
poolMembers = [p for p in meta.members.all() if p.pool.isVisible() and p.pool.isUsable()]
|
||||
poolMembers: typing.List[MetaPoolMember] = [p for p in meta.members.all() if p.pool.isVisible() and p.pool.isUsable()] # type: ignore
|
||||
# Sort pools based on meta selection
|
||||
if meta.policy == MetaPool.PRIORITY_POOL:
|
||||
sortPools = [(p.priority, p.pool) for p in poolMembers]
|
||||
elif meta.policy == MetaPool.MOST_AVAILABLE_BY_NUMBER:
|
||||
sortPools = [(p.usage(), p) for p in poolMembers]
|
||||
sortPools = [(p.pool.usage(), p.pool) for p in poolMembers]
|
||||
else:
|
||||
sortPools = [(random.randint(0, 10000), p) for p in poolMembers] # Just shuffle them
|
||||
sortPools = [(random.randint(0, 10000), p.pool) for p in poolMembers] # Just shuffle them
|
||||
|
||||
# Sort pools related to policy now, and xtract only pools, not sort keys
|
||||
# Remove "full" pools (100%) from result and pools in maintenance mode, not ready pools, etc...
|
||||
|
Loading…
x
Reference in New Issue
Block a user