update printRateLimitWait/bump zfin for cache improvements

This commit is contained in:
Emil Lerch 2026-06-01 12:41:35 -07:00
parent 56244024ff
commit b422718f3a
Signed by: lobo
GPG key ID: A7B62D657EF764F8
2 changed files with 13 additions and 13 deletions

View file

@ -14,8 +14,8 @@
.hash = "httpz-0.0.0-PNVzrLjJCAD37S0CcrXpsjSqr86hVjK0rsALTDJ98AAJ",
},
.zfin = .{
.url = "git+https://git.lerch.org/lobo/zfin#641a88b0b768769a33e3f95fa6f1736fa58e4a6f",
.hash = "zfin-0.0.0-J-B21mEEPACavg9MPzB402B3DIzfIxXhNv3UOAyFHBxK",
.url = "git+https://git.lerch.org/lobo/zfin#4d65cc45f4fd7c71a4222d2d3c7c41100acd7069",
.hash = "zfin-0.0.0-J-B21ls4PADNXleWi_cuaAYNjBWEO0FfO3qyBnCPtE3R",
},
},
}

View file

@ -416,8 +416,8 @@ fn upperDupe(allocator: std.mem.Allocator, s: []const u8) ![]u8 {
return d;
}
fn printRateLimitWait(svc: *zfin.DataService, stdout: *std.Io.Writer) !void {
if (svc.estimateWaitSeconds()) |wait| {
fn printRateLimitWait(svc: *zfin.DataService, data_type: zfin.cache.DataType, stdout: *std.Io.Writer) !void {
if (svc.estimateWaitSeconds(data_type)) |wait| {
if (wait > 0) {
try stdout.print("\n (rate limit -- waiting {d}s)\n ", .{wait});
try stdout.flush();
@ -558,7 +558,7 @@ fn refresh(io: std.Io, allocator: std.mem.Allocator, environ: *const std.process
// handlers to serve. Per-symbol `getEtfMetrics` calls below
// also rely on these maps being loaded.
{
try printRateLimitWait(&svc, stdout);
try printRateLimitWait(&svc, .tickers_funds, stdout);
if (svc.loadMutualFundTickerMap(.{})) |mut_map| {
var m = mut_map;
m.deinit();
@ -566,7 +566,7 @@ fn refresh(io: std.Io, allocator: std.mem.Allocator, environ: *const std.process
} else |err| {
try stdout.print("EDGAR mutual-fund ticker map FAILED ({t})\n", .{err});
}
try printRateLimitWait(&svc, stdout);
try printRateLimitWait(&svc, .tickers_companies, stdout);
if (svc.loadCompanyTickerMap(.{})) |co_map| {
var m = co_map;
m.deinit();
@ -586,7 +586,7 @@ fn refresh(io: std.Io, allocator: std.mem.Allocator, environ: *const std.process
var sym_ok = true;
// Candles
try printRateLimitWait(&svc, stdout);
try printRateLimitWait(&svc, .candles_daily, stdout);
if (svc.getCandles(sym, .{})) |result| {
defer result.deinit();
try stdout.print("candles ok ({s})", .{@tagName(result.source)});
@ -604,7 +604,7 @@ fn refresh(io: std.Io, allocator: std.mem.Allocator, environ: *const std.process
}
// Dividends
try printRateLimitWait(&svc, stdout);
try printRateLimitWait(&svc, .dividends, stdout);
if (svc.getDividends(sym, .{})) |result| {
defer result.deinit();
try stdout.print(", dividends ok ({s})", .{@tagName(result.source)});
@ -614,7 +614,7 @@ fn refresh(io: std.Io, allocator: std.mem.Allocator, environ: *const std.process
}
// Splits
try printRateLimitWait(&svc, stdout);
try printRateLimitWait(&svc, .splits, stdout);
if (svc.getSplits(sym, .{})) |result| {
defer result.deinit();
try stdout.print(", splits ok ({s})", .{@tagName(result.source)});
@ -624,7 +624,7 @@ fn refresh(io: std.Io, allocator: std.mem.Allocator, environ: *const std.process
}
// Earnings
try printRateLimitWait(&svc, stdout);
try printRateLimitWait(&svc, .earnings, stdout);
if (svc.getEarnings(sym, .{})) |result| {
defer result.deinit();
try stdout.print(", earnings ok ({s})", .{@tagName(result.source)});
@ -639,7 +639,7 @@ fn refresh(io: std.Io, allocator: std.mem.Allocator, environ: *const std.process
// Wikidata entry) and doesn't flip sym_ok.
var cik_buf: ?[]u8 = null;
defer if (cik_buf) |b| allocator.free(b);
try printRateLimitWait(&svc, stdout);
try printRateLimitWait(&svc, .classification, stdout);
if (svc.getClassification(sym, .{})) |result| {
defer result.deinit();
if (result.data.len > 0) {
@ -660,7 +660,7 @@ fn refresh(io: std.Io, allocator: std.mem.Allocator, environ: *const std.process
// non-funds (NPORT-P only exists for funds + UITs); a
// negative-cache entry suppresses retries. Logged as
// `n/a` and doesn't flip sym_ok.
try printRateLimitWait(&svc, stdout);
try printRateLimitWait(&svc, .etf_metrics, stdout);
if (svc.getEtfMetrics(sym, .{})) |result| {
defer result.deinit();
try stdout.print(", etf_metrics ok ({s})", .{@tagName(result.source)});
@ -679,7 +679,7 @@ fn refresh(io: std.Io, allocator: std.mem.Allocator, environ: *const std.process
// zfin chains entity_facts off Wikidata's CIK, so the
// server warms the cache the same way).
if (cik_buf) |cik| {
try printRateLimitWait(&svc, stdout);
try printRateLimitWait(&svc, .entity_facts, stdout);
if (svc.getEntityFacts(cik, .{})) |result| {
defer result.deinit();
try stdout.print(", entity_facts ok ({s})", .{@tagName(result.source)});