fix: typing fixes since moving to Mapped types in models
This commit is contained in:
parent
d08388c339
commit
4693e994ba
5 changed files with 71 additions and 44 deletions
|
@ -80,6 +80,9 @@ def calculate_subgroup_count(proxies: Optional[List[Proxy]] = None) -> SubgroupC
|
|||
proxies = all_active_proxies()
|
||||
subgroup_count: SubgroupCount = OrderedDict()
|
||||
for proxy in proxies:
|
||||
if not proxy.psg:
|
||||
logging.warning("Proxy %s has no psg", proxy.id)
|
||||
continue
|
||||
if proxy.provider not in subgroup_count:
|
||||
subgroup_count[proxy.provider] = OrderedDict()
|
||||
if proxy.origin.group_id not in subgroup_count[proxy.provider]:
|
||||
|
@ -142,6 +145,7 @@ def auto_deprecate_proxies() -> None:
|
|||
days=1, seconds=86400 * random.random()) # nosec: B311
|
||||
if proxy.added < max_age_cutoff:
|
||||
proxy.deprecate(reason="max_age_reached")
|
||||
proxy.destroy()
|
||||
|
||||
|
||||
def destroy_expired_proxies() -> None:
|
||||
|
@ -298,6 +302,16 @@ class ProxyMetaAutomation(BaseAutomation):
|
|||
Origin.destroyed.is_(None)
|
||||
).all()
|
||||
for origin in origins:
|
||||
if origin.countries:
|
||||
risk_levels = origin.risk_level.items()
|
||||
highest_risk_country = max(risk_levels, key=lambda x: x[1])
|
||||
highest_risk_level = highest_risk_country[1]
|
||||
if highest_risk_level < 4:
|
||||
for proxy in origin.proxies:
|
||||
if proxy.destroyed is None and proxy.pool_id == -1:
|
||||
logging.debug("Destroying hot spare proxy for origin %s (low risk)", origin)
|
||||
proxy.destroy()
|
||||
continue
|
||||
if origin.destroyed is not None:
|
||||
continue
|
||||
proxies = Proxy.query.filter(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue