Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
Cost: compact Odoo read-through status
Browse files
api/routes_odoo_tables.py
CHANGED
|
@@ -153,15 +153,33 @@ def refresh_odoo_tables(session: Session = Depends(require_session)):
|
|
| 153 |
|
| 154 |
|
| 155 |
@router.get("/odoo-tables/status")
|
| 156 |
-
def odoo_tables_status(
|
|
|
|
| 157 |
"""Row counts + the newest `refreshed` stamp per table.
|
| 158 |
|
| 159 |
β The stamp is the whole point while the resync wiring is outstanding: a locked collections
|
| 160 |
worklist that quietly stopped updating is a worklist that lies, so its age must be readable
|
| 161 |
without anybody running a refresh to find out.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 162 |
"""
|
| 163 |
-
rel
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 164 |
import core.user_tables as user_tables
|
|
|
|
|
|
|
|
|
|
|
|
|
| 165 |
# β W30-T31 β THE ELIGIBILITY PASS RUNS HERE TOO, and the mirror cursor is taken best-effort:
|
| 166 |
# the freshness surface must answer on a box with no mirror (that is what it is FOR), so a
|
| 167 |
# store that is not ready costs the size half of the question, never the whole endpoint.
|
|
@@ -187,7 +205,7 @@ def odoo_tables_status(session: Session = Depends(require_session)):
|
|
| 187 |
# hard-coded list here would have reported "everything is fine" over two databases it had
|
| 188 |
# stopped knowing about ([[gate-answers-the-wrong-question]] β the hard-coded count).
|
| 189 |
for _bucket, key, _label, _fields in rel.TABLES:
|
| 190 |
-
table =
|
| 191 |
rows = (table.get("rows") or {})
|
| 192 |
stamps = [str((r or {}).get("refreshed") or "") for r in rows.values()]
|
| 193 |
# ββ A FRESHNESS SURFACE THAT LIES IS WORSE THAN NO FRESHNESS SURFACE, and this endpoint
|
|
@@ -196,7 +214,7 @@ def odoo_tables_status(session: Session = Depends(require_session)):
|
|
| 196 |
# operator would see a database that looks EMPTY and STALE on a route whose own docstring
|
| 197 |
# says a worklist that quietly stopped updating must be legible without a refresh. So a
|
| 198 |
# read-through table is counted from the MIRROR and says where its count came from.
|
| 199 |
-
materialised = user_tables.materialises(key,
|
| 200 |
if not materialised:
|
| 201 |
try:
|
| 202 |
rows = {}
|
|
|
|
| 153 |
|
| 154 |
|
| 155 |
@router.get("/odoo-tables/status")
|
| 156 |
+
def odoo_tables_status(brief: bool = Query(False),
|
| 157 |
+
session: Session = Depends(require_session)):
|
| 158 |
"""Row counts + the newest `refreshed` stamp per table.
|
| 159 |
|
| 160 |
β The stamp is the whole point while the resync wiring is outstanding: a locked collections
|
| 161 |
worklist that quietly stopped updating is a worklist that lies, so its age must be readable
|
| 162 |
without anybody running a refresh to find out.
|
| 163 |
+
|
| 164 |
+
`brief=1` is the grid's one question at open time: which declared tables read through the
|
| 165 |
+
mirror? It deliberately does not borrow the tenant document, take a mirror cursor, or count
|
| 166 |
+
rows. Those would be work solely for metadata the client never reads. The source registry
|
| 167 |
+
remains the authority, so a future conversion is still discovered server-side rather than by
|
| 168 |
+
a client-side key list.
|
| 169 |
"""
|
| 170 |
+
rel = _rel()
|
| 171 |
+
if brief:
|
| 172 |
+
sources = _sources()
|
| 173 |
+
return {"ok": True, "tables": {
|
| 174 |
+
key: {"readThrough": key in sources}
|
| 175 |
+
for _bucket, key, _label, _fields in rel.TABLES
|
| 176 |
+
}}
|
| 177 |
+
|
| 178 |
import core.user_tables as user_tables
|
| 179 |
+
# The detailed operator view genuinely needs rows to report counts/freshness, but it needs
|
| 180 |
+
# them ONCE. Repeated `get()` calls each copy the same tenant document under the store lock.
|
| 181 |
+
tables = user_tables.all_tables(st=session.runtime)
|
| 182 |
+
out = {}
|
| 183 |
# β W30-T31 β THE ELIGIBILITY PASS RUNS HERE TOO, and the mirror cursor is taken best-effort:
|
| 184 |
# the freshness surface must answer on a box with no mirror (that is what it is FOR), so a
|
| 185 |
# store that is not ready costs the size half of the question, never the whole endpoint.
|
|
|
|
| 205 |
# hard-coded list here would have reported "everything is fine" over two databases it had
|
| 206 |
# stopped knowing about ([[gate-answers-the-wrong-question]] β the hard-coded count).
|
| 207 |
for _bucket, key, _label, _fields in rel.TABLES:
|
| 208 |
+
table = tables.get(key) or {}
|
| 209 |
rows = (table.get("rows") or {})
|
| 210 |
stamps = [str((r or {}).get("refreshed") or "") for r in rows.values()]
|
| 211 |
# ββ A FRESHNESS SURFACE THAT LIES IS WORSE THAN NO FRESHNESS SURFACE, and this endpoint
|
|
|
|
| 214 |
# operator would see a database that looks EMPTY and STALE on a route whose own docstring
|
| 215 |
# says a worklist that quietly stopped updating must be legible without a refresh. So a
|
| 216 |
# read-through table is counted from the MIRROR and says where its count came from.
|
| 217 |
+
materialised = user_tables.materialises(key, defn=table)
|
| 218 |
if not materialised:
|
| 219 |
try:
|
| 220 |
rows = {}
|
web/src/customer-grid/apiBridge.ts
CHANGED
|
@@ -439,7 +439,9 @@ export function readThroughTables(): Promise<Set<string>> {
|
|
| 439 |
if (!readThroughMemo) {
|
| 440 |
readThroughMemo = (async () => {
|
| 441 |
try {
|
| 442 |
-
|
|
|
|
|
|
|
| 443 |
if (handledSession(res) || !res.ok) {
|
| 444 |
readThroughMemo = null;
|
| 445 |
return new Set<string>();
|
|
|
|
| 439 |
if (!readThroughMemo) {
|
| 440 |
readThroughMemo = (async () => {
|
| 441 |
try {
|
| 442 |
+
// The grid needs only the read-through flag, never the operator status's counts/stamps.
|
| 443 |
+
// `brief=1` is server-derived from the connected-grid registry and reads no table rows.
|
| 444 |
+
const res = await fetch(`${API_V1}/odoo-tables/status?brief=1`, { credentials: CREDENTIALS });
|
| 445 |
if (handledSession(res) || !res.ok) {
|
| 446 |
readThroughMemo = null;
|
| 447 |
return new Set<string>();
|