sort reverse chronological - now we have a lot more data
This commit is contained in:
parent
0c08cdda6c
commit
9bb0d8036b
2 changed files with 9 additions and 4 deletions
|
|
@ -16,11 +16,14 @@ pub fn run(allocator: std.mem.Allocator, svc: *zfin.DataService, symbol: []const
|
|||
};
|
||||
defer allocator.free(result.data);
|
||||
|
||||
// Sort chronologically (oldest first) — providers may return in any order
|
||||
// Sort newest-first — the first row is the most recent quarter, which
|
||||
// is the dominant query. Matches `git log` / `ls -lt` / `last` defaults
|
||||
// and the TUI. `| head -N` gives you the N most recent quarters;
|
||||
// `| tail` still works if you want oldest-first.
|
||||
if (result.data.len > 1) {
|
||||
std.mem.sort(zfin.EarningsEvent, result.data, {}, struct {
|
||||
fn f(_: void, a: zfin.EarningsEvent, b: zfin.EarningsEvent) bool {
|
||||
return a.date.days < b.date.days;
|
||||
return a.date.days > b.date.days;
|
||||
}
|
||||
}.f);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,11 +34,13 @@ pub fn loadData(app: *App) void {
|
|||
app.earnings_data = result.data;
|
||||
app.earnings_timestamp = result.timestamp;
|
||||
|
||||
// Sort chronologically (oldest first) — providers may return in any order
|
||||
// Sort newest-first — this is what users expect on earnings tables
|
||||
// everywhere (Yahoo, Morningstar, etc.) and keeps the most relevant
|
||||
// quarter on the first visible row.
|
||||
if (result.data.len > 1) {
|
||||
std.mem.sort(zfin.EarningsEvent, result.data, {}, struct {
|
||||
fn f(_: void, a: zfin.EarningsEvent, b: zfin.EarningsEvent) bool {
|
||||
return a.date.days < b.date.days;
|
||||
return a.date.days > b.date.days;
|
||||
}
|
||||
}.f);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue