Skip to content

Commit 21f4e1f

Browse files
M03EDImMohammad20000
authored andcommitted
fix: format
1 parent fb2a3a8 commit 21f4e1f

File tree

4 files changed

+13
-18
lines changed

4 files changed

+13
-18
lines changed

app/jobs/node_checker.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ async def verify_node_backend_health(node: PasarGuardNode, node_name: str) -> tu
3737
logger.debug(f"[{node_name}] Node health is HEALTHY")
3838
return Health.HEALTHY, None, None
3939
except NodeAPIError as e:
40-
logger.error(f"[{node_name}] Health check failed, setting health to BROKEN | Error: NodeAPIError(code={e.code}) - {e.detail}")
40+
logger.error(
41+
f"[{node_name}] Health check failed, setting health to BROKEN | Error: NodeAPIError(code={e.code}) - {e.detail}"
42+
)
4143
try:
4244
await node.set_health(Health.BROKEN)
4345
return Health.BROKEN, e.code, e.detail
@@ -104,13 +106,13 @@ async def process_node_health_check(db_node: Node, node: PasarGuardNode):
104106
# Skip nodes that are already healthy and connected
105107
if health == Health.HEALTHY and db_node.status == NodeStatus.connected:
106108
return
107-
109+
108110
# Handle hard reset requirement
109111
if node.requires_hard_reset():
110112
async with GetDB() as db:
111113
await node_operator.connect_single_node(db, db_node.id)
112114
return
113-
115+
114116
if health is Health.INVALID:
115117
logger.warning(f"[{db_node.name}] Node health is INVALID, ignoring...")
116118
return
@@ -125,9 +127,7 @@ async def process_node_health_check(db_node: Node, node: PasarGuardNode):
125127
if health == Health.BROKEN:
126128
# Record actual error in database
127129
async with GetDB() as db:
128-
await NodeOperation._update_single_node_status(
129-
db, db_node.id, NodeStatus.error, message=error_message
130-
)
130+
await NodeOperation._update_single_node_status(db, db_node.id, NodeStatus.error, message=error_message)
131131
# Only reconnect for non-timeout errors (code > -1)
132132
if error_code is not None and error_code > -1:
133133
async with GetDB() as db:

app/node/user.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from PasarGuardNodeBridge import create_proxy, create_user
2-
from sqlalchemy import Text, and_, cast, func, select
2+
from sqlalchemy import and_, func, select
33

44
from app.db import AsyncSession
55
from app.db.models import Group, ProxyInbound, User, UserStatus, inbounds_groups_association, users_groups_association
@@ -31,12 +31,9 @@ async def core_users(db: AsyncSession):
3131
# Use dialect-specific aggregation and grouping
3232
if dialect == "postgresql":
3333
inbound_agg = func.string_agg(ProxyInbound.tag.distinct(), ",").label("inbound_tags")
34-
# PostgreSQL can't GROUP BY JSON directly, cast to text
35-
proxy_settings_group = cast(User.proxy_settings, Text)
3634
else:
3735
# MySQL and SQLite use group_concat
3836
inbound_agg = func.group_concat(ProxyInbound.tag.distinct()).label("inbound_tags")
39-
proxy_settings_group = User.proxy_settings
4037

4138
stmt = (
4239
select(
@@ -56,7 +53,7 @@ async def core_users(db: AsyncSession):
5653
.outerjoin(inbounds_groups_association, Group.id == inbounds_groups_association.c.group_id)
5754
.outerjoin(ProxyInbound, inbounds_groups_association.c.inbound_id == ProxyInbound.id)
5855
.where(User.status.in_([UserStatus.active, UserStatus.on_hold]))
59-
.group_by(User.id, User.username, proxy_settings_group)
56+
.group_by(User.id)
6057
)
6158

6259
results = (await db.execute(stmt)).all()

app/operation/subscription.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def create_info_response_headers(user: UsersResponseWithInbounds, sub_settings:
105105
"announce": encode_title(sub_settings.announce),
106106
"announce-url": sub_settings.announce_url,
107107
}
108-
108+
109109
# Only include headers that have values
110110
return {k: v for k, v in headers.items() if v}
111111

@@ -193,10 +193,10 @@ async def user_subscription_info(
193193
sub_settings: SubSettings = await subscription_settings()
194194
db_user = await self.get_validated_sub(db, token=token)
195195
user = await self.validated_user(db_user)
196-
196+
197197
response_headers = self.create_info_response_headers(user, sub_settings)
198198
user_response = SubscriptionUserResponse.model_validate(db_user.__dict__)
199-
199+
200200
return user_response, response_headers
201201

202202
async def user_subscription_apps(self, db: AsyncSession, token: str, request_url: str) -> list[Application]:

app/routers/subscription.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,12 @@ async def user_subscription(
3434

3535

3636
@router.get("/{token}/info", response_model=SubscriptionUserResponse)
37-
async def user_subscription_info(
38-
request: Request, token: str, db: AsyncSession = Depends(get_db)
39-
):
37+
async def user_subscription_info(request: Request, token: str, db: AsyncSession = Depends(get_db)):
4038
"""Retrieves detailed information about the user's subscription."""
4139
user_data, response_headers = await subscription_operator.user_subscription_info(
4240
db, token=token, request_url=str(request.url)
4341
)
44-
return JSONResponse(content=user_data.model_dump(mode='json'), headers=response_headers)
42+
return JSONResponse(content=user_data.model_dump(mode="json"), headers=response_headers)
4543

4644

4745
@router.get("/{token}/apps", response_model=list[Application])

0 commit comments

Comments
 (0)