fsanyoto commited on
Commit
6dffc73
·
verified ·
1 Parent(s): bd7fcd1

Deploy AIOS web (React glide grid + FastAPI slice)

Browse files
RELEASES.json CHANGED
@@ -1,4 +1,4 @@
1
  {
2
- "current": "fe5f25c0f",
3
  "releases": []
4
  }
 
1
  {
2
+ "current": "a1b404564",
3
  "releases": []
4
  }
VERSION CHANGED
@@ -1 +1 @@
1
- fe5f25c0f
 
1
+ a1b404564
api/assistant_mirror.py CHANGED
@@ -120,6 +120,31 @@ def unavailable_reason(table_key, definition=None):
120
  return NO_BINDING
121
 
122
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
123
  def binding(cur, table_key):
124
  """The resolved read-through spec for one connected grid, or None when it has no binding.
125
 
 
120
  return NO_BINDING
121
 
122
 
123
+ def still_loading(table_key):
124
+ """True while an Odoo table behind this binding is in its first backfill, so its rows are partial.
125
+
126
+ Evidence only: a `_sync_state` phase other than live, or an empty table with no state row yet
127
+ (created, first batch not written). A mirror with no sync bookkeeping is not loading.
128
+ """
129
+ from harness import datastore
130
+ try:
131
+ spec = _rot()._sources().get(str(table_key or "")) or {}
132
+ names = set((spec.get("tables") or {}).values()) | ({spec["table"]} if spec.get("table") else set())
133
+ cur = datastore.ro_cursor()
134
+ try:
135
+ for name in sorted(n for n in names if n in datastore.ENTITIES):
136
+ row = cur.execute("SELECT phase FROM _sync_state WHERE entity = ?", [name]).fetchone()
137
+ if row is not None and row[0] != "live":
138
+ return True
139
+ if row is None and not cur.execute(f"SELECT count(*) FROM (SELECT 1 FROM {name} LIMIT 1)").fetchone()[0]:
140
+ return True
141
+ finally:
142
+ cur.close()
143
+ except Exception: # noqa: BLE001
144
+ return False
145
+ return False
146
+
147
+
148
  def binding(cur, table_key):
149
  """The resolved read-through spec for one connected grid, or None when it has no binding.
150
 
api/deps.py CHANGED
@@ -490,7 +490,7 @@ def _assistant_mirror_table(session: Session, database: str, requested_fields=No
490
  if refusal is not None:
491
  _assistant_refuse(refusal.status, refusal.code, refusal.message)
492
  spec = assistant_mirror.binding(cur, database)
493
- if spec is None:
494
  _assistant_refuse(409, "assistant_snapshot_unavailable",
495
  assistant_mirror.unavailable_reason(database, definition))
496
  fields = assistant_mirror.answerable_fields(database, spec, declared)
@@ -1183,10 +1183,10 @@ def assistant_source_status(session: Session, databases=None):
1183
  bound = assistant_mirror.is_bound(cur, key)
1184
  except Exception: # noqa: BLE001
1185
  bound = False
1186
- if bound:
 
1187
  row["answerable"] = True
1188
  else:
1189
- import assistant_mirror
1190
  row["reason"] = assistant_mirror.unavailable_reason(key, definition)
1191
  return out
1192
 
 
490
  if refusal is not None:
491
  _assistant_refuse(refusal.status, refusal.code, refusal.message)
492
  spec = assistant_mirror.binding(cur, database)
493
+ if spec is None or assistant_mirror.still_loading(database):
494
  _assistant_refuse(409, "assistant_snapshot_unavailable",
495
  assistant_mirror.unavailable_reason(database, definition))
496
  fields = assistant_mirror.answerable_fields(database, spec, declared)
 
1183
  bound = assistant_mirror.is_bound(cur, key)
1184
  except Exception: # noqa: BLE001
1185
  bound = False
1186
+ import assistant_mirror
1187
+ if bound and not assistant_mirror.still_loading(key):
1188
  row["answerable"] = True
1189
  else:
 
1190
  row["reason"] = assistant_mirror.unavailable_reason(key, definition)
1191
  return out
1192
 
api/main.py CHANGED
@@ -1960,7 +1960,7 @@ def _resync_mirror_pass(manual, passes, entities=None):
1960
  # relational rebuild, which `manual` says nothing about.
1961
  if manual:
1962
  return None, None, None
1963
- absent = _absent_mirror_entities(_ds, entities)
1964
  first = {}
1965
  if absent:
1966
  # Tables the boot seed lacks first: minutes, where the whole catch-up runs an hour.
@@ -2002,6 +2002,17 @@ def _absent_mirror_entities(ds, entities=None):
2002
  return []
2003
 
2004
 
 
 
 
 
 
 
 
 
 
 
 
2005
  def _classify_resync_error(exc):
2006
  """D-314, the half that fits inside this loop: a failed pass leaves a MARK, not just a line.
2007
 
 
1960
  # relational rebuild, which `manual` says nothing about.
1961
  if manual:
1962
  return None, None, None
1963
+ absent = _smallest_first(_ds, _absent_mirror_entities(_ds, entities))
1964
  first = {}
1965
  if absent:
1966
  # Tables the boot seed lacks first: minutes, where the whole catch-up runs an hour.
 
2002
  return []
2003
 
2004
 
2005
+ def _smallest_first(ds, keys):
2006
+ """`keys` ordered by their Odoo row count, so a small table answers before a large backfill."""
2007
+ def size(key):
2008
+ try:
2009
+ spec = ds.ENTITIES[key]
2010
+ return int(ds.O.get_odoo().search_count(spec["model"], ds._base_domain(spec)))
2011
+ except Exception: # noqa: BLE001
2012
+ return float("inf")
2013
+ return sorted(keys, key=size)
2014
+
2015
+
2016
  def _classify_resync_error(exc):
2017
  """D-314, the half that fits inside this loop: a failed pass leaves a MARK, not just a line.
2018
 
web/public/AIOS_DEPLOY_RECEIPT CHANGED
@@ -1 +1 @@
1
- 4073c7bb3f0821ae686c33783c33d634088e1ecb973bedefd18728b446704658
 
1
+ 5ab5e13703f388069a3d63b8c33c383db925cc8932667a8dd6214bd2c6e13ab9