Offer the current exercise through an explicit API switch.
Deploy Development / deploy (push) Successful in 53s
Test Suite / pytest-backend (push) Failing after 29s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 16s
Test Suite / k6 /health Baseline (push) Successful in 35s
Test Suite / playwright-tests (push) Failing after 7m42s
Deploy Development / deploy (push) Successful in 53s
Test Suite / pytest-backend (push) Failing after 29s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 16s
Test Suite / k6 /health Baseline (push) Successful in 35s
Test Suite / playwright-tests (push) Failing after 7m42s
The exercise list turns the live catalog on or off for the caller's edit rights. A distribution key reads that current selection and the changes since its last cursor. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
4ad62b6e38
commit
b59b7eae16
13 files changed
+488
-5
No files matched your search
@@ -30,6 +30,8 @@ from distribution_service import (
|
||||
issue_key,
|
||||
list_changes,
|
||||
list_release_drift,
|
||||
load_catalog,
|
||||
load_catalog_exercise,
|
||||
load_asset,
|
||||
load_availability,
|
||||
load_manifest,
|
||||
@@ -144,6 +146,65 @@ class ReasonBody(BaseModel):
|
||||
reason_code: str
|
||||
|
||||
|
||||
@router.get("/catalog")
|
||||
def get_catalog(cursor: Optional[str] = None, authorization: Optional[str] = Header(default=None)):
|
||||
binding = _machine(authorization)
|
||||
try:
|
||||
assert_exercise_object(binding.get("objects"))
|
||||
except HTTPException as exc:
|
||||
exc.headers = {**(exc.headers or {}), **NO_STORE}
|
||||
raise exc
|
||||
held: Optional[HTTPException] = None
|
||||
payload = None
|
||||
with get_db() as conn:
|
||||
cur = get_cursor(conn)
|
||||
try:
|
||||
payload = load_catalog(cur, binding, cursor)
|
||||
except InvalidCursor:
|
||||
held = HTTPException(
|
||||
status_code=400,
|
||||
detail={"code": "invalid_cursor", "message": "Cursor ungültig."},
|
||||
)
|
||||
except HTTPException as exc:
|
||||
held = exc
|
||||
else:
|
||||
conn.commit()
|
||||
if held is not None:
|
||||
held.headers = {**(held.headers or {}), **NO_STORE}
|
||||
raise held
|
||||
return Response(
|
||||
content=__import__("json").dumps(payload, ensure_ascii=False, separators=(",", ":")),
|
||||
media_type="application/json",
|
||||
headers=NO_STORE,
|
||||
)
|
||||
|
||||
|
||||
@router.get("/catalog/{source_id}")
|
||||
def get_catalog_exercise(source_id: str, authorization: Optional[str] = Header(default=None)):
|
||||
binding = _machine(authorization)
|
||||
try:
|
||||
assert_exercise_object(binding.get("objects"))
|
||||
except HTTPException as exc:
|
||||
exc.headers = {**(exc.headers or {}), **NO_STORE}
|
||||
raise exc
|
||||
held: Optional[HTTPException] = None
|
||||
payload = None
|
||||
with get_db() as conn:
|
||||
cur = get_cursor(conn)
|
||||
try:
|
||||
payload = load_catalog_exercise(cur, binding, source_id)
|
||||
except HTTPException as exc:
|
||||
held = exc
|
||||
if held is not None:
|
||||
held.headers = {**(held.headers or {}), **NO_STORE}
|
||||
raise held
|
||||
return Response(
|
||||
content=__import__("json").dumps(payload, ensure_ascii=False, separators=(",", ":")),
|
||||
media_type="application/json",
|
||||
headers=NO_STORE,
|
||||
)
|
||||
|
||||
|
||||
@router.get("/changes")
|
||||
def get_changes(
|
||||
cursor: Optional[str] = None,
|
||||
|
||||
Reference in new issue
Block a user