Compare commits
4 Commits
fe0c108363
...
d23d84ea42
| Author | SHA1 | Date | |
|---|---|---|---|
| d23d84ea42 | |||
| 7d6cdcbe02 | |||
| 0e95f94025 | |||
| 8b1a09fbd4 |
@@ -1 +1 @@
|
|||||||
271261202
|
271261322
|
||||||
|
|||||||
@@ -11,7 +11,14 @@ from ..clients.radarr import RadarrClient
|
|||||||
from ..clients.prowlarr import ProwlarrClient
|
from ..clients.prowlarr import ProwlarrClient
|
||||||
from ..clients.qbittorrent import QBittorrentClient
|
from ..clients.qbittorrent import QBittorrentClient
|
||||||
from ..runtime import get_runtime_settings
|
from ..runtime import get_runtime_settings
|
||||||
from ..db import save_snapshot, get_request_cache_payload, get_recent_snapshots, get_setting, set_setting
|
from ..db import (
|
||||||
|
save_snapshot,
|
||||||
|
get_request_cache_payload,
|
||||||
|
get_request_cache_by_id,
|
||||||
|
get_recent_snapshots,
|
||||||
|
get_setting,
|
||||||
|
set_setting,
|
||||||
|
)
|
||||||
from ..models import ActionOption, NormalizedState, RequestType, Snapshot, TimelineHop
|
from ..models import ActionOption, NormalizedState, RequestType, Snapshot, TimelineHop
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@@ -219,6 +226,19 @@ async def build_snapshot(request_id: str) -> Snapshot:
|
|||||||
logging.getLogger(__name__).debug(
|
logging.getLogger(__name__).debug(
|
||||||
"snapshot cache miss: request_id=%s mode=%s", request_id, mode
|
"snapshot cache miss: request_id=%s mode=%s", request_id, mode
|
||||||
)
|
)
|
||||||
|
if cached_request is not None:
|
||||||
|
cache_meta = get_request_cache_by_id(int(request_id))
|
||||||
|
cached_title = cache_meta.get("title") if cache_meta else None
|
||||||
|
if cached_title and isinstance(cached_request, dict):
|
||||||
|
media = cached_request.get("media")
|
||||||
|
if not isinstance(media, dict):
|
||||||
|
media = {}
|
||||||
|
cached_request["media"] = media
|
||||||
|
if not media.get("title") and not media.get("name"):
|
||||||
|
media["title"] = cached_title
|
||||||
|
media["name"] = cached_title
|
||||||
|
if not cached_request.get("title") and not cached_request.get("name"):
|
||||||
|
cached_request["title"] = cached_title
|
||||||
|
|
||||||
allow_remote = mode == "always_js" and jellyseerr.configured()
|
allow_remote = mode == "always_js" and jellyseerr.configured()
|
||||||
if not jellyseerr.configured() and not cached_request:
|
if not jellyseerr.configured() and not cached_request:
|
||||||
@@ -259,10 +279,18 @@ async def build_snapshot(request_id: str) -> Snapshot:
|
|||||||
jelly_status = jelly_request.get("status", "unknown")
|
jelly_status = jelly_request.get("status", "unknown")
|
||||||
jelly_status_label = _status_label(jelly_status)
|
jelly_status_label = _status_label(jelly_status)
|
||||||
jelly_type = jelly_request.get("type") or "unknown"
|
jelly_type = jelly_request.get("type") or "unknown"
|
||||||
snapshot.title = jelly_request.get("media", {}).get("title", "Unknown")
|
|
||||||
snapshot.year = jelly_request.get("media", {}).get("year")
|
|
||||||
snapshot.request_type = RequestType(jelly_type) if jelly_type in {"movie", "tv"} else RequestType.unknown
|
|
||||||
media = jelly_request.get("media", {}) if isinstance(jelly_request, dict) else {}
|
media = jelly_request.get("media", {}) if isinstance(jelly_request, dict) else {}
|
||||||
|
if not isinstance(media, dict):
|
||||||
|
media = {}
|
||||||
|
snapshot.title = (
|
||||||
|
media.get("title")
|
||||||
|
or media.get("name")
|
||||||
|
or jelly_request.get("title")
|
||||||
|
or jelly_request.get("name")
|
||||||
|
or "Unknown"
|
||||||
|
)
|
||||||
|
snapshot.year = media.get("year") or jelly_request.get("year")
|
||||||
|
snapshot.request_type = RequestType(jelly_type) if jelly_type in {"movie", "tv"} else RequestType.unknown
|
||||||
poster_path = None
|
poster_path = None
|
||||||
backdrop_path = None
|
backdrop_path = None
|
||||||
if isinstance(media, dict):
|
if isinstance(media, dict):
|
||||||
|
|||||||
@@ -125,6 +125,7 @@ export default function SettingsPage({ section }: SettingsPageProps) {
|
|||||||
const [cacheRows, setCacheRows] = useState<any[]>([])
|
const [cacheRows, setCacheRows] = useState<any[]>([])
|
||||||
const [cacheCount, setCacheCount] = useState(50)
|
const [cacheCount, setCacheCount] = useState(50)
|
||||||
const [cacheStatus, setCacheStatus] = useState<string | null>(null)
|
const [cacheStatus, setCacheStatus] = useState<string | null>(null)
|
||||||
|
const [cacheLoading, setCacheLoading] = useState(false)
|
||||||
const [requestsSync, setRequestsSync] = useState<any | null>(null)
|
const [requestsSync, setRequestsSync] = useState<any | null>(null)
|
||||||
const [artworkPrefetch, setArtworkPrefetch] = useState<any | null>(null)
|
const [artworkPrefetch, setArtworkPrefetch] = useState<any | null>(null)
|
||||||
const [artworkSummary, setArtworkSummary] = useState<any | null>(null)
|
const [artworkSummary, setArtworkSummary] = useState<any | null>(null)
|
||||||
@@ -667,6 +668,7 @@ export default function SettingsPage({ section }: SettingsPageProps) {
|
|||||||
|
|
||||||
const loadCache = async () => {
|
const loadCache = async () => {
|
||||||
setCacheStatus(null)
|
setCacheStatus(null)
|
||||||
|
setCacheLoading(true)
|
||||||
try {
|
try {
|
||||||
const baseUrl = getApiBase()
|
const baseUrl = getApiBase()
|
||||||
const response = await authFetch(
|
const response = await authFetch(
|
||||||
@@ -689,6 +691,8 @@ export default function SettingsPage({ section }: SettingsPageProps) {
|
|||||||
? err.message.replace(/^\\{\"detail\":\"|\"\\}$/g, '')
|
? err.message.replace(/^\\{\"detail\":\"|\"\\}$/g, '')
|
||||||
: 'Could not load cache.'
|
: 'Could not load cache.'
|
||||||
setCacheStatus(message)
|
setCacheStatus(message)
|
||||||
|
} finally {
|
||||||
|
setCacheLoading(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1378,8 +1382,15 @@ export default function SettingsPage({ section }: SettingsPageProps) {
|
|||||||
<option value={200}>200</option>
|
<option value={200}>200</option>
|
||||||
</select>
|
</select>
|
||||||
</label>
|
</label>
|
||||||
<button type="button" onClick={loadCache}>
|
<button type="button" onClick={loadCache} disabled={cacheLoading}>
|
||||||
Load saved requests
|
{cacheLoading ? (
|
||||||
|
<>
|
||||||
|
<span className="spinner button-spinner" aria-hidden="true" />
|
||||||
|
Loading saved requests
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
'Load saved requests'
|
||||||
|
)}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1689,6 +1689,16 @@ button span {
|
|||||||
animation: spin 0.9s linear infinite;
|
animation: spin 0.9s linear infinite;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.button-spinner {
|
||||||
|
width: 16px;
|
||||||
|
height: 16px;
|
||||||
|
border-width: 2px;
|
||||||
|
box-shadow: none;
|
||||||
|
margin-right: 8px;
|
||||||
|
vertical-align: middle;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
.loading-text {
|
.loading-text {
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
color: var(--ink-muted);
|
color: var(--ink-muted);
|
||||||
|
|||||||
Reference in New Issue
Block a user