mirror of
https://github.com/0xrsydn/idx-cli.git
synced 2026-11-07 09:45:36 +00:00
fix(ownership): one release order everywhere; keep the old search API
From the Codex re-gate of the 0.3.3 fixes: - `changes` broke ties between same-date releases by row id, but the ticker, entity, and graph queries and the snapshot builder did not, so two files imported in the same second could resolve differently per query. Order by as_of_date, imported_at, then id everywhere. - search::fts_search and search::rebuild_fts were public in a published crate; keep them as deprecated wrappers. - Invalid --source and --by are INVALIDINPUT, like other argument errors. - The prefix-ranking test could not tell prefix from exact-alias ranking; add one where only prefix vs substring differs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01V3syn2fN2LNo5pvTSqc6eh
This commit is contained in:
parent
1d3fe5ca88
commit
6abc4a0712
5 changed files with 63 additions and 8 deletions
|
|
@ -797,7 +797,7 @@ pub fn query_releases(conn: &Connection) -> Result<Vec<OwnershipRelease>, IdxErr
|
|||
.prepare(
|
||||
"SELECT id, source_url, sha256, as_of_date, row_count, imported_at
|
||||
FROM ownership_releases
|
||||
ORDER BY as_of_date DESC, imported_at DESC",
|
||||
ORDER BY as_of_date DESC, imported_at DESC, id DESC",
|
||||
)
|
||||
.map_err(|e| IdxError::DatabaseError(e.to_string()))?;
|
||||
|
||||
|
|
@ -1298,7 +1298,7 @@ fn latest_ksei_release(conn: &Connection) -> Result<Option<LatestKseiRelease>, I
|
|||
conn.query_row(
|
||||
"SELECT sha256, as_of_date
|
||||
FROM ownership_releases
|
||||
ORDER BY as_of_date DESC, imported_at DESC
|
||||
ORDER BY as_of_date DESC, imported_at DESC, id DESC
|
||||
LIMIT 1",
|
||||
[],
|
||||
|row| {
|
||||
|
|
@ -1544,6 +1544,39 @@ mod tests {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn same_second_imports_resolve_to_the_later_file_everywhere() {
|
||||
// Original and corrected file for one date imported in the same
|
||||
// second: the ticker view and `changes` must read the same one.
|
||||
let conn = setup();
|
||||
let bbca = upsert_ticker(&conn, "BBCA", None).unwrap();
|
||||
let alpha = entity(&conn, "ALPHA");
|
||||
write_release(
|
||||
&conn,
|
||||
"jan",
|
||||
"2026-01-30",
|
||||
7,
|
||||
bbca,
|
||||
&[(Some(alpha), "ALPHA", 1000)],
|
||||
);
|
||||
write_release(
|
||||
&conn,
|
||||
"jan-fix",
|
||||
"2026-01-30",
|
||||
7,
|
||||
bbca,
|
||||
&[(Some(alpha), "ALPHA", 1200)],
|
||||
);
|
||||
|
||||
let ticker = query_ticker_holdings(&conn, "BBCA").unwrap();
|
||||
|
||||
assert_eq!(
|
||||
ticker.holders[0].percentage_bps, 1200,
|
||||
"{:?}",
|
||||
ticker.holders
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn changes_reject_a_date_without_a_release() {
|
||||
let conn = setup();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue