Skip to content

fix(search): stop emitting 1970-01-01 when the search timestamp is a string or zero - #158

Merged
hogan-yuan merged 1 commit into
mainfrom
fix/search-time-epoch
Sep 21, 2026
Merged

hogan-yuan merged 1 commit into
mainfrom
fix/search-time-epoch

Conversation

@hogan-yuan

Copy link
Copy Markdown
Member

Problem

news_search and topic_search render "time": "1970-01-01T00:00:00Z" for every item.

Root cause

The transforms read publish_at_timestamp / created_at_timestamp with v.as_i64().unwrap_or(0). The upstream serializes these int64 values as JSON strings (to avoid JS precision loss), so as_i64() returns None → 0 → epoch. A genuine numeric 0 lands there too. Either way every affected item shows 1970-01-01T00:00:00Z.

Fix

  • New as_unix_ts helper parses the timestamp robustly — JSON number, float, or string — and returns None for a missing / non-positive / unparseable value.
  • news/topic transforms use it and omit time when there's no valid timestamp, rather than emitting a misleading epoch.

Tests

Regression tests for both the news and topic transforms cover:

  • string-encoded timestamp → real RFC3339 time (not 1970);
  • numeric timestamp → unchanged;
  • missing / 0 / "0" / "" / non-numeric / null → time omitted.

cargo test (316 passed), clippy --all-features --all-targets, and +nightly fmt all clean. Independent of the mainland/.cn change.

…string or zero

news_search / topic_search read `publish_at_timestamp` / `created_at_timestamp`
with `v.as_i64().unwrap_or(0)`. The upstream serializes these int64 values as
JSON strings (to avoid JS precision loss), so `as_i64()` returns None → 0 →
`1970-01-01T00:00:00Z`; a genuine numeric 0 lands there too. Every affected
item rendered the epoch.

Parse the timestamp robustly (number, float, or string) via a new `as_unix_ts`
helper, and omit `time` entirely for a missing/zero/unparseable value instead of
emitting a misleading epoch. Regression tests cover string, numeric, and
missing/zero/unparseable inputs for both the news and topic transforms.
@hogan-yuan
hogan-yuan merged commit ed7674e into main Sep 21, 2026
1 check passed
@hogan-yuan
hogan-yuan deleted the fix/search-time-epoch branch September 21, 2026 07:19
hogan-yuan added a commit that referenced this pull request Sep 21, 2026
Minor release from 0.11.2. Includes a breaking change:

- feat(symbol)!: send symbols instead of counter_ids, add multi-leg orders (#128)
- fix(tools): strip non-standard schema formats (uint/int64/…) (#156)
- fix(search): stop emitting 1970-01-01 when the search timestamp is a string or zero (#158)

Bumps Cargo.toml, Cargo.lock, and server.json (version + image identifier).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant