fsanyoto commited on
Commit
ce0d7d8
Β·
verified Β·
1 Parent(s): 5f26852

Deploy AIOS web (React glide grid + FastAPI slice)

Browse files
Files changed (3) hide show
  1. RELEASES.json +1 -1
  2. VERSION +1 -1
  3. api/automation_engine.py +48 -13
RELEASES.json CHANGED
@@ -1,5 +1,5 @@
1
  {
2
- "current": "0a70c23",
3
  "releases": [
4
  {
5
  "version": "v14",
 
1
  {
2
+ "current": "872f5c5",
3
  "releases": [
4
  {
5
  "version": "v14",
VERSION CHANGED
@@ -1 +1 @@
1
- 0a70c23
 
1
+ 872f5c5
api/automation_engine.py CHANGED
@@ -2015,9 +2015,15 @@ POST_FIELDS = [
2015
  #: 2. PRIVACY β€” Bright Data flags `comment_user` and `post_user` as PII, and the append law has
2016
  #: no erasure path for third parties who never appeared in the tracked set (D-24). A comment
2017
  #: thread ingests identifiable people who never entered anybody's influencer list.
2018
- #: β‡’ So capture rides an OPT-IN switch defaulted OFF (`config.comments`), the same posture as
2019
- #: `config.postMetrics` and the Bright Data money switch W26/R15 kept. The relation costs nothing;
2020
- #: the spend and the third-party ingest are a click somebody makes knowingly.
 
 
 
 
 
 
2021
  #: ⚠ `BD_NEVER_MAP` STILL STRIPS `latest_comments` β€” the array of 15 comment texts a POSTS row
2022
  #: carries whether we asked or not. Turning this on does not open that door; it is a separate
2023
  #: dataset with a separate decision, and R11's enforcement point is unchanged.
@@ -7874,25 +7880,38 @@ ROLLUP_MAX_CHARS = 4000
7874
 
7875
 
7876
  def _sort_key(value, ftype):
7877
- """One cell β†’ a sortable key, typed by the LINKED field's declared type.
 
7878
 
7879
  β›” TYPE-AWARE ON PURPOSE. `posted_at` is a `date` and `views` is an `int`; sorting either as a
7880
  string puts `2026-9-1` before `2026-10-1` and `9` after `100`. Since `sortBy` is what decides
7881
  WHICH rows a `limit` keeps, getting this wrong does not mis-order a display β€” it silently
7882
  averages the wrong twelve posts.
7883
- ⚠ A blank sorts LAST under `desc` and FIRST under `asc` β€” i.e. always at the far end from
7884
- "most recent" β€” because an unknown date is not a recent one. Same law as `posts_window`.
 
 
 
 
 
 
 
 
 
 
 
 
7885
  """
7886
  raw = "" if value is None else str(value).strip()
7887
  if raw == "":
7888
- return (1, 0.0, "")
7889
  if ftype in ("int", "currency", "pct", "rating"):
7890
  n = _lane_num(raw)
7891
- return (0, n, "") if n is not None else (1, 0.0, "")
7892
  if ftype == "date":
7893
  d = _parse_iso(raw.replace(" ", "T"))
7894
- return (0, d.timestamp(), "") if d is not None else (1, 0.0, "")
7895
- return (0, 0.0, raw.lower())
7896
 
7897
 
7898
  def _rollup_fold(fn, values):
@@ -8045,8 +8064,16 @@ def compute_relation_cells(rt, table_key):
8045
  sort_by = str(bag.get("sortBy") or "")
8046
  if sort_by:
8047
  ftype = (linked_types.get(lk_key) or {}).get(sort_by, "text")
8048
- hits.sort(key=lambda pair, _s=sort_by, _t=ftype: _sort_key(pair[1].get(_s), _t),
8049
- reverse=str(bag.get("sortDir") or "desc") == "desc")
 
 
 
 
 
 
 
 
8050
  limit = int(bag.get("limit") or 0)
8051
  if limit:
8052
  hits = hits[:limit]
@@ -8078,7 +8105,15 @@ def refresh_relations(rt, log=print):
8078
  table declaring neither kind costs one dict scan.
8079
  """
8080
  touched = 0
8081
- for tk in list(ut_all(rt).keys()):
 
 
 
 
 
 
 
 
8082
  try:
8083
  touched += compute_relation_cells(rt, tk)
8084
  except Exception as e: # noqa: BLE001
 
2015
  #: 2. PRIVACY β€” Bright Data flags `comment_user` and `post_user` as PII, and the append law has
2016
  #: no erasure path for third parties who never appeared in the tracked set (D-24). A comment
2017
  #: thread ingests identifiable people who never entered anybody's influencer list.
2018
+ #: β›” SO WHAT SHIPS HERE IS THE SCHEMA AND THE LINK. **NOTHING CAPTURES COMMENTS TODAY** β€” no code
2019
+ #: calls Bright Data's Comments dataset (`gd_ltppn085pokosxh13`), there is no `config.comments`
2020
+ #: switch, and this table stays EMPTY until somebody builds one. Stated in the present tense on
2021
+ #: purpose: an earlier draft of this note described the opt-in switch as if it existed, which is
2022
+ #: exactly the doc that "reads as authority and silently ages" that Β§0 of `instagram-capture.md`
2023
+ #: is written against.
2024
+ #: ⚠ WHEN IT IS BUILT it should be an OPT-IN defaulted OFF, the same posture as
2025
+ #: `config.postMetrics` and the Bright Data money switch W26/R15 kept β€” the relation costs
2026
+ #: nothing; the spend and the third-party ingest are a click somebody makes knowingly.
2027
  #: ⚠ `BD_NEVER_MAP` STILL STRIPS `latest_comments` β€” the array of 15 comment texts a POSTS row
2028
  #: carries whether we asked or not. Turning this on does not open that door; it is a separate
2029
  #: dataset with a separate decision, and R11's enforcement point is unchanged.
 
7880
 
7881
 
7882
  def _sort_key(value, ftype):
7883
+ """One cell β†’ a sortable key, typed by the LINKED field's declared type. `None` when the cell
7884
+ is blank or does not parse as its declared type.
7885
 
7886
  β›” TYPE-AWARE ON PURPOSE. `posted_at` is a `date` and `views` is an `int`; sorting either as a
7887
  string puts `2026-9-1` before `2026-10-1` and `9` after `100`. Since `sortBy` is what decides
7888
  WHICH rows a `limit` keeps, getting this wrong does not mis-order a display β€” it silently
7889
  averages the wrong twelve posts.
7890
+
7891
+ β›”β›” **BLANKS ARE PARTITIONED OUT BY THE CALLER, NEVER RANKED BY A FLAG β€” AND THE FLAG VERSION
7892
+ SHIPPED BROKEN FOR ONE DEPLOY.** This returned `(1, 0.0, "")` for a blank and `(0, key, "")`
7893
+ otherwise, documented as "a blank sorts LAST under desc". It does the OPPOSITE: `reverse=True`
7894
+ flips the whole tuple, so `(1, …)` sorted FIRST and an undated row displaced the most recent
7895
+ real one out of the window. A sentinel inside the key cannot mean "last" in both directions,
7896
+ because the direction is applied to the sentinel too.
7897
+ ⚠ AND IT WAS NOT A CORNER CASE ON THE RUNG THAT MATTERS: `wave20-split` MEASURED `datetime` as
7898
+ `None` on 24/24 posts from the Profiles dataset, and `_bd_post_identity` writes `posted_at`
7899
+ only when the vendor sent one β€” so on a paid profile pull EVERY post row is blank here, every
7900
+ key tied, and `limit 12` took whatever twelve came first in dict order. The e2e test passed
7901
+ because its fixture posts all carried dates.
7902
+ β‡’ `None` means "not comparable", the caller keeps those rows at the END whichever way it
7903
+ sorts, and "an unknown date is not a recent one" is finally what the code does.
7904
  """
7905
  raw = "" if value is None else str(value).strip()
7906
  if raw == "":
7907
+ return None
7908
  if ftype in ("int", "currency", "pct", "rating"):
7909
  n = _lane_num(raw)
7910
+ return (n,) if n is not None else None
7911
  if ftype == "date":
7912
  d = _parse_iso(raw.replace(" ", "T"))
7913
+ return (d.timestamp(),) if d is not None else None
7914
+ return (raw.lower(),)
7915
 
7916
 
7917
  def _rollup_fold(fn, values):
 
8064
  sort_by = str(bag.get("sortBy") or "")
8065
  if sort_by:
8066
  ftype = (linked_types.get(lk_key) or {}).get(sort_by, "text")
8067
+ # β›” PARTITION, THEN SORT. A row whose sort cell is blank or unparseable is not
8068
+ # rankable, and it must land at the END whichever direction is asked for β€” which
8069
+ # a sentinel inside the sort key cannot do, because `reverse` flips the sentinel
8070
+ # too (see `_sort_key`). Unrankable rows are appended, so a `limit` spends its
8071
+ # window on rows that HAVE the value before it falls back to ones that do not.
8072
+ keyed = [(pair, _sort_key(pair[1].get(sort_by), ftype)) for pair in hits]
8073
+ rankable = [(p, k) for p, k in keyed if k is not None]
8074
+ rankable.sort(key=lambda pk: pk[1],
8075
+ reverse=str(bag.get("sortDir") or "desc") == "desc")
8076
+ hits = [p for p, _k in rankable] + [p for p, k in keyed if k is None]
8077
  limit = int(bag.get("limit") or 0)
8078
  if limit:
8079
  hits = hits[:limit]
 
8105
  table declaring neither kind costs one dict scan.
8106
  """
8107
  touched = 0
8108
+ # ⚠ FILTER OFF THE DICT ALREADY IN HAND, exactly as `refresh_metrics` does. Calling
8109
+ # `compute_relation_cells` for every table would make it re-`ut_get` each one just to
8110
+ # discover it declares neither kind β€” so the "costs one dict scan" claim above is only true
8111
+ # with this line, and without it the sibling two functions down does strictly less work for
8112
+ # the same job.
8113
+ for tk, t in ut_all(rt).items():
8114
+ fs = (t or {}).get("fields") or []
8115
+ if not any(f.get("type") == "rollup" or _ut().is_derived_link(f) for f in fs):
8116
+ continue
8117
  try:
8118
  touched += compute_relation_cells(rt, tk)
8119
  except Exception as e: # noqa: BLE001