kopia lustrzana https://github.com/bugout-dev/moonstream
Update delete subscriptions.
rodzic
6376d97c40
commit
e7f942e636
|
@ -615,6 +615,11 @@ def delete_seer_subscription(
|
||||||
"""
|
"""
|
||||||
|
|
||||||
## Delete subscription from db
|
## Delete subscription from db
|
||||||
|
associated_jobs = db_session.query(AbiSubscriptions.abi_job_id).filter(
|
||||||
|
AbiSubscriptions.subscription_id == subscription_id
|
||||||
|
).all()
|
||||||
|
job_ids = [job_id for (job_id,) in associated_jobs]
|
||||||
|
# Delete subscription from db
|
||||||
|
|
||||||
try:
|
try:
|
||||||
db_session.query(AbiSubscriptions).filter(
|
db_session.query(AbiSubscriptions).filter(
|
||||||
|
@ -622,29 +627,20 @@ def delete_seer_subscription(
|
||||||
).delete(synchronize_session=False)
|
).delete(synchronize_session=False)
|
||||||
db_session.commit()
|
db_session.commit()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Error delete subscription from db: {str(e)}")
|
logger.error(f"Error deleting subscription from db: {str(e)}")
|
||||||
db_session.rollback()
|
db_session.rollback()
|
||||||
|
return
|
||||||
|
|
||||||
not_connected_abi_jobs = (
|
if job_ids:
|
||||||
db_session.query(AbiJobs)
|
|
||||||
.join(AbiSubscriptions, AbiJobs.id == AbiSubscriptions.abi_job_id, isouter=True)
|
|
||||||
.filter(AbiSubscriptions.subscription_id == None)
|
|
||||||
.cte("not_connected_abi_jobs")
|
|
||||||
)
|
|
||||||
|
|
||||||
## Delete abi jobs from db
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
db_session.query(AbiJobs).filter(
|
db_session.query(AbiJobs).filter(
|
||||||
AbiJobs.id.in_(db_session.query(not_connected_abi_jobs.c.id))
|
AbiJobs.id.in_(job_ids)
|
||||||
).delete(synchronize_session=False)
|
).delete(synchronize_session=False)
|
||||||
|
|
||||||
db_session.commit()
|
db_session.commit()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Error delete abi jobs from db: {str(e)}")
|
logger.error(f"Error deleting abi jobs from db: {str(e)}")
|
||||||
db_session.rollback()
|
db_session.rollback()
|
||||||
|
|
||||||
|
|
||||||
def add_abi_to_db(
|
def add_abi_to_db(
|
||||||
db_session: Session,
|
db_session: Session,
|
||||||
user_id: uuid.UUID,
|
user_id: uuid.UUID,
|
||||||
|
|
|
@ -2,4 +2,4 @@
|
||||||
Moonstream library and API version.
|
Moonstream library and API version.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
MOONSTREAMAPI_VERSION = "0.4.11"
|
MOONSTREAMAPI_VERSION = "0.4.12"
|
||||||
|
|
Ładowanie…
Reference in New Issue