Skip to content

Commit

Permalink
add 查询所有站点最新用户数据 api
Browse files Browse the repository at this point in the history
  • Loading branch information
jxxghp committed Oct 17, 2024
1 parent c02c19d commit a4bf59a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
15 changes: 14 additions & 1 deletion app/api/endpoints/site.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,20 @@ def refresh_userdata(
return schemas.Response(success=True, data=user_data)


@router.get("/userdata/{site_id}", summary="查询站点用户数据", response_model=schemas.Response)
@router.get("/userdata/latest", summary="查询所有站点最新用户数据", response_model=List[schemas.SiteUserData])
def read_userdata_latest(
db: Session = Depends(get_db),
_: schemas.TokenPayload = Depends(get_current_active_superuser)) -> Any:
"""
查询所有站点最新用户数据
"""
user_datas = SiteUserData.get_latest(db)
if not user_datas:
return []
return [user_data.to_dict() for user_data in user_datas]


@router.get("/userdata/{site_id}", summary="查询某站点用户数据", response_model=schemas.Response)
def read_userdata(
site_id: int,
workdate: str = None,
Expand Down
2 changes: 1 addition & 1 deletion app/modules/transmission/transmission.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def get_completed_torrents(self, ids: Union[str, list] = None,
if not self.trc:
return None
try:
torrents, error = self.get_torrents(status=["seeding", "seed_pending"], ids=ids, tags=tags)
torrents, error = self.get_torrents(status=["", "seed_pending"], ids=ids, tags=tags)
return None if error else torrents or []
except Exception as err:
logger.error(f"获取已完成的种子列表出错:{str(err)}")
Expand Down

0 comments on commit a4bf59a

Please sign in to comment.