Fix production ARR reads and add audited source field review

This commit is contained in:
Wyndham ARR committed 2026-10-08 17:01:54 +08:00
1 parent 2417b1a41c
commit fe8735aac2
26 files changed
+2417 -157

No files matched your search

+8 -8
View File
@@ -15,7 +15,7 @@ from . import profile_summary, rate_info
FETCH = tuple(value for value in base.FETCH if value != "Traces")
OPERATIONS = (base.SEARCH, base.DETAIL, rate_info.POST, profile_summary.OPERATION,
OPERATIONS = (base.SEARCH, base.DETAIL, rate_info.POST, profile_summary.GET_OPERATION,
"getProfile", "getBlock", "getRoomCalendar", "getPackage")
require = base.require
@@ -83,11 +83,12 @@ class DataReader:
day = self.options.arrival_date
if operation == base.SEARCH:
require(identity is None and params is None and type(body) is dict, "invalid_search_request")
require(set(body) == {"arrivalStartDate", "arrivalEndDate", "limit", "offset", "orderBy", "sortOrder"}
# Optional sorting is rejected by production. Retain the returned
# order and the full end-of-batch recheck rather than guessing a sort.
require(set(body) == {"arrivalStartDate", "arrivalEndDate", "limit", "offset"}
and body["arrivalStartDate"] == body["arrivalEndDate"] == day
and body["limit"] == self.options.page_size and type(body["limit"]) is int
and type(body["offset"]) is int and 0 <= body["offset"] < self.options.max_pages * self.options.page_size
and body["orderBy"] == ["ConfirmationNo"] and body["sortOrder"] == ["Asc"],
and type(body["offset"]) is int and 0 <= body["offset"] < self.options.max_pages * self.options.page_size,
"invalid_search_request")
return "POST", "/api/v1/reservations/searches", body
require(body is None, "unexpected_query_body")
@@ -123,9 +124,8 @@ class DataReader:
if operation == rate_info.POST:
method, path, _payload, value = rate_info.request(identity, day)
return method, path, value
if operation == profile_summary.OPERATION:
method, path, payload = profile_summary.request(identity)
return method, path, base.strict_json(payload)
if operation == profile_summary.GET_OPERATION:
return profile_summary.get_request(identity)
if operation == "getProfile":
return "GET", f"/api/v1/profiles/{identity}", None
return "GET", f"/api/v1/blocks/{identity}?fetchInstructions=Block", None
@@ -176,7 +176,7 @@ class DataReader:
# Reservation details/day prices are used once, and calendars once
# per page. Bound reusable related-object caching in both bytes and
# entries so a large day cannot retain every raw response in RAM.
if operation in (profile_summary.OPERATION, "getProfile", "getBlock", "getPackage"):
if operation in (profile_summary.GET_OPERATION, "getProfile", "getBlock", "getPackage"):
while self.cache and (len(self.cache) >= 128 or self.cache_bytes + len(raw) > 32 * 1024 * 1024):
_key, evicted = self.cache.popitem(last=False)
self.cache_bytes -= len(evicted.raw)