Major JQL bugfixes
This commit is contained in:
+24
-1
@@ -12,7 +12,7 @@ import datetime as dt
|
||||
from typing import List, Tuple, TypedDict
|
||||
|
||||
from PyQt6.QtCore import QThread, pyqtSignal
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy import select, delete
|
||||
|
||||
from app.database import get_session
|
||||
from app.models import Order
|
||||
@@ -216,6 +216,29 @@ def save_orders(orders: List[NormalizedOrder]) -> SaveResult:
|
||||
)
|
||||
|
||||
|
||||
def reset_local_database() -> int:
|
||||
"""
|
||||
Wipes every locally cached order. This is a rebuildable cache, not a
|
||||
system of record - JIRA is - so this is always safe, just requires
|
||||
re-running Import from JIRA (and Pull Tracking Numbers) afterward.
|
||||
|
||||
Also the real fix for one specific situation: a ticket that
|
||||
transitioned status under an older, buggy version of this app can end
|
||||
up with a permanently-wrong fulfilled_at/cancelled_at timestamp, since
|
||||
those are only recalculated ON a transition - re-importing an
|
||||
already-transitioned ticket finds "no change" and never touches it
|
||||
again. A reset clears that stale timestamp entirely; the fresh
|
||||
re-import then stamps everything correctly from scratch.
|
||||
"""
|
||||
session = get_session()
|
||||
try:
|
||||
result = session.execute(delete(Order))
|
||||
session.commit()
|
||||
return result.rowcount or 0
|
||||
finally:
|
||||
session.close()
|
||||
|
||||
|
||||
def load_all_orders() -> List[Order]:
|
||||
session = get_session()
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user