Skip to content

Commit

Permalink
fix api
Browse files Browse the repository at this point in the history
  • Loading branch information
jxxghp committed Apr 19, 2024
1 parent 4e7000e commit ebf2f53
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/api/endpoints/douban.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
router = APIRouter()


@router.get("/img/{imgurl:path}", summary="豆瓣图片代理")
@router.get("/img", summary="豆瓣图片代理")
def douban_img(imgurl: str) -> Any:
"""
豆瓣图片代理
Expand Down
12 changes: 7 additions & 5 deletions app/db/sytestatistic_oper.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ def success(self, domain: str, seconds: int = None):
sta = SiteStatistic.get_by_domain(self._db, domain)
if sta:
avg_seconds, note = None, {}
if seconds:
if seconds is not None:
note: dict = json.loads(sta.note or "{}")
note[lst_date] = seconds
note[lst_date] = seconds or 1
avg_times = len(note.keys())
if avg_times > 10:
note = dict(sorted(note.items(), key=lambda x: x[0], reverse=True)[:10])
avg_seconds = sum([v for v in note.values()]) // avg_times
sta.update(self._db, {
"success": sta.success + 1,
Expand All @@ -32,15 +34,15 @@ def success(self, domain: str, seconds: int = None):
})
else:
note = {}
if seconds:
if seconds is not None:
note = {
lst_date: seconds
lst_date: seconds or 1
}
SiteStatistic(
domain=domain,
success=1,
fail=0,
seconds=seconds,
seconds=seconds or 1,
lst_state=0,
lst_mod_date=lst_date,
note=json.dumps(note)
Expand Down

0 comments on commit ebf2f53

Please sign in to comment.