mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-07 00:16:57 +08:00
feat(subscribe): update get_by_state to handle multiple states
This commit is contained in:
@@ -54,7 +54,7 @@ class Subscribe(Base):
|
|||||||
lack_episode = Column(Integer)
|
lack_episode = Column(Integer)
|
||||||
# 附加信息
|
# 附加信息
|
||||||
note = Column(JSON)
|
note = Column(JSON)
|
||||||
# 状态:N-新建, R-订阅中
|
# 状态:N-新建 R-订阅中 P-待定 S-暂停
|
||||||
state = Column(String, nullable=False, index=True, default='N')
|
state = Column(String, nullable=False, index=True, default='N')
|
||||||
# 最后更新时间
|
# 最后更新时间
|
||||||
last_update = Column(String)
|
last_update = Column(String)
|
||||||
@@ -98,7 +98,13 @@ class Subscribe(Base):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
@db_query
|
@db_query
|
||||||
def get_by_state(db: Session, state: str):
|
def get_by_state(db: Session, state: str):
|
||||||
result = db.query(Subscribe).filter(Subscribe.state == state).all()
|
# 如果 state 为空或 None,返回所有订阅
|
||||||
|
if not state:
|
||||||
|
result = db.query(Subscribe).all()
|
||||||
|
else:
|
||||||
|
# 如果传入的状态不为空,拆分成多个状态
|
||||||
|
states = state.split(',')
|
||||||
|
result = db.query(Subscribe).filter(Subscribe.state.in_(states)).all()
|
||||||
return list(result)
|
return list(result)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|||||||
Reference in New Issue
Block a user