Jambase aufgeräumt und Backup script
This commit is contained in:
+25
-4
@@ -25,7 +25,8 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
PROVIDER_PRIORITY = {
|
||||
"ticketmaster": 3,
|
||||
"ticketmaster": 4,
|
||||
"jambase": 3,
|
||||
"eventim": 2,
|
||||
"bandsintown": 1,
|
||||
}
|
||||
@@ -126,6 +127,8 @@ def init_provider_sync_state(provider_name: str) -> dict:
|
||||
"ok_count": 0,
|
||||
"blocked_terms": [],
|
||||
"error_terms": [],
|
||||
"event_count": 0,
|
||||
"raw_event_count": 0,
|
||||
"last_message": "",
|
||||
}
|
||||
|
||||
@@ -135,12 +138,17 @@ def record_provider_sync_state(
|
||||
status: ProviderStatusType,
|
||||
term: str,
|
||||
message: str,
|
||||
event_count: int = 0,
|
||||
raw_event_count: int | None = None,
|
||||
):
|
||||
if PROVIDER_STATUS_PRIORITY[status] > PROVIDER_STATUS_PRIORITY[state["status"]]:
|
||||
state["status"] = status
|
||||
|
||||
if status == ProviderStatusType.ok:
|
||||
state["ok_count"] += 1
|
||||
state["event_count"] += event_count
|
||||
if raw_event_count is not None:
|
||||
state["raw_event_count"] += raw_event_count
|
||||
elif status == ProviderStatusType.blocked:
|
||||
if term not in state["blocked_terms"]:
|
||||
state["blocked_terms"].append(term)
|
||||
@@ -166,7 +174,12 @@ def build_provider_status_message(state: dict) -> str:
|
||||
|
||||
return (
|
||||
f"{state['provider_name']} erfolgreich fuer {state['ok_count']} "
|
||||
f"Watchlist-Eintraege geprueft."
|
||||
f"Watchlist-Eintraege geprueft, {state['event_count']} passende Events."
|
||||
+ (
|
||||
f" {state['raw_event_count']} Roh-Events ausgewertet."
|
||||
if state["raw_event_count"]
|
||||
else ""
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@@ -214,19 +227,25 @@ def events_are_equivalent(left: TrackedEvent, right: TrackedEvent) -> bool:
|
||||
def is_preferred_event(candidate: TrackedEvent, current: TrackedEvent) -> bool:
|
||||
candidate_score = (
|
||||
1 if candidate.is_ticket_purchased else 0,
|
||||
PROVIDER_PRIORITY.get(candidate.source, 0),
|
||||
get_provider_priority(candidate.source),
|
||||
1 if candidate.ticket_url else 0,
|
||||
candidate.last_seen_at or datetime.min,
|
||||
)
|
||||
current_score = (
|
||||
1 if current.is_ticket_purchased else 0,
|
||||
PROVIDER_PRIORITY.get(current.source, 0),
|
||||
get_provider_priority(current.source),
|
||||
1 if current.ticket_url else 0,
|
||||
current.last_seen_at or datetime.min,
|
||||
)
|
||||
return candidate_score > current_score
|
||||
|
||||
|
||||
def get_provider_priority(source: str | None) -> int:
|
||||
if source and source.startswith("source:"):
|
||||
return 5
|
||||
return PROVIDER_PRIORITY.get(source or "", 0)
|
||||
|
||||
|
||||
def has_equivalent_existing_event(db: Session, tracked_event: TrackedEvent) -> bool:
|
||||
stmt = select(TrackedEvent).where(
|
||||
TrackedEvent.watch_item_id == tracked_event.watch_item_id,
|
||||
@@ -411,6 +430,8 @@ def run_sync(db: Session) -> SyncResult:
|
||||
status=ProviderStatusType(provider_status_name),
|
||||
term=watch_item.name,
|
||||
message=provider_message,
|
||||
event_count=len(events),
|
||||
raw_event_count=getattr(provider, "last_raw_count", None),
|
||||
)
|
||||
except Exception as exc:
|
||||
provider_message = getattr(
|
||||
|
||||
Reference in New Issue
Block a user