Skip to content

Commit 2c43fcc

Browse files
committed
fix: torrent.hash exists but bangumi_id is None
1 parent 4e89507 commit 2c43fcc

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

backend/src/module/database/torrent.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import logging
22
from typing import Optional
33

4-
from sqlmodel import Session, select
4+
from sqlmodel import Session, select, and_, desc
55

66
from module.models import Torrent
77

@@ -59,5 +59,7 @@ def check_new(self, torrents_list: list[Torrent]) -> list[Torrent]:
5959

6060
def get_bangumi_id(self, torrent_hash: str) -> Optional[int]:
6161
return self.session.exec(
62-
select(Torrent.bangumi_id).where(Torrent.hash == torrent_hash)
62+
select(Torrent.bangumi_id)
63+
.where(and_(Torrent.hash == torrent_hash, Torrent.bangumi_id.isnot(None)))
64+
.order_by(desc(Torrent.id))
6365
).first()

0 commit comments

Comments
 (0)