remove dead code
All checks were successful
Generic zig build / build (push) Successful in 4m59s
Generic zig build / deploy (push) Successful in 24s
Generic zig build / publish-macos (push) Successful in 1m15s

This commit is contained in:
Emil Lerch 2026-08-03 23:18:23 -07:00
parent 1d2cf32806
commit a3d235bd39
Signed by: lobo
GPG key ID: A7B62D657EF764F8
3 changed files with 8 additions and 49 deletions

View file

@ -709,11 +709,7 @@ pub fn load(
var load_all = self.svc.loadAllPrices( var load_all = self.svc.loadAllPrices(
syms, syms,
watch_syms_list.items, watch_syms_list.items,
.{ opts.fetch_options,
.force_refresh = opts.fetch_options.force_refresh,
.skip_network = opts.fetch_options.skip_network,
.color = false, // pd doesn't render; caller's progress callback owns UI.
},
opts.aggregate_progress, opts.aggregate_progress,
sym_cb, sym_cb,
); );

View file

@ -295,7 +295,7 @@ pub fn loadPortfolioPrices(
.grand_total = (if (portfolio_syms) |ps| ps.len else 0) + watch_syms.len, .grand_total = (if (portfolio_syms) |ps| ps.len else 0) + watch_syms.len,
}; };
// Map RefreshPolicy -> LoadAllConfig: // `fetchOptionsFromPolicy` maps the flag; what each policy means here:
// .force -> ignore TTL; incremental candle top-up (no wipe). // .force -> ignore TTL; incremental candle top-up (no wipe).
// .auto -> respect TTL, fetch on stale. // .auto -> respect TTL, fetch on stale.
// .never -> offline mode: never touch the network. Stale cache // .never -> offline mode: never touch the network. Stale cache
@ -303,11 +303,7 @@ pub fn loadPortfolioPrices(
const result = svc.loadAllPrices( const result = svc.loadAllPrices(
portfolio_syms, portfolio_syms,
watch_syms, watch_syms,
.{ fetchOptionsFromPolicy(refresh),
.force_refresh = refresh == .force,
.skip_network = refresh == .never,
.color = color,
},
aggregate.callback(), aggregate.callback(),
symbol_progress.callback(), symbol_progress.callback(),
); );

View file

@ -2122,22 +2122,6 @@ pub const DataService = struct {
// Consolidated Price Loading (Parallel Server + Sequential Provider) // Consolidated Price Loading (Parallel Server + Sequential Provider)
/// Configuration for loadAllPrices. /// Configuration for loadAllPrices.
pub const LoadAllConfig = struct {
force_refresh: bool = false,
/// Skip provider fetches and server sync. Returns cached
/// data (even if stale) and treats cache miss as failure.
/// Drives `--refresh-data=never`.
skip_network: bool = false,
color: bool = true,
/// Map this config to the per-call `FetchOptions` shape.
/// Convenience for paths that need to pass through to
/// `getCandles`/`getDividends`/etc.
pub fn fetchOptions(self: LoadAllConfig) FetchOptions {
return .{ .skip_network = self.skip_network, .force_refresh = self.force_refresh };
}
};
/// Result of loadAllPrices operation. /// Result of loadAllPrices operation.
pub const LoadAllResult = struct { pub const LoadAllResult = struct {
prices: std.StringHashMap(f64), prices: std.StringHashMap(f64),
@ -2217,7 +2201,7 @@ pub const DataService = struct {
self: *DataService, self: *DataService,
portfolio_syms: ?[]const []const u8, portfolio_syms: ?[]const []const u8,
watch_syms: []const []const u8, watch_syms: []const []const u8,
config: LoadAllConfig, opts: FetchOptions,
aggregate_progress: ?AggregateProgressCallback, aggregate_progress: ?AggregateProgressCallback,
symbol_progress: ?ProgressCallback, symbol_progress: ?ProgressCallback,
) LoadAllResult { ) LoadAllResult {
@ -2248,7 +2232,7 @@ pub const DataService = struct {
for (watch_syms) |sym| all_symbols.append(self.allocator, sym) catch |err| log.warn("loadAllPrices append watch sym({s}): {t}", .{ sym, err }); for (watch_syms) |sym| all_symbols.append(self.allocator, sym) catch |err| log.warn("loadAllPrices append watch sym({s}): {t}", .{ sym, err });
// force_refresh does NOT wipe the candle cache. It flows // force_refresh does NOT wipe the candle cache. It flows
// through to getCandles (via config.fetchOptions()), which // through to getCandles (the same `opts` we were handed), which
// ignores the TTL and does an incremental top-up - see the // ignores the TTL and does an incremental top-up - see the
// `--refresh-data=force` contract. The Phase-1 fast path below // `--refresh-data=force` contract. The Phase-1 fast path below
// is skipped on force_refresh so every symbol is re-validated // is skipped on force_refresh so every symbol is re-validated
@ -2262,7 +2246,7 @@ pub const DataService = struct {
if (aggregate_progress) |p| p.emit(0, total_count, .cache_check); if (aggregate_progress) |p| p.emit(0, total_count, .cache_check);
for (all_symbols.items) |sym| { for (all_symbols.items) |sym| {
if (!config.force_refresh and self.isCandleCacheFresh(sym)) { if (!opts.force_refresh and self.isCandleCacheFresh(sym)) {
if (self.getCachedLastClose(sym)) |close| { if (self.getCachedLastClose(sym)) |close| {
result.prices.put(sym, close) catch |err| log.warn("loadAllPrices cache-hit put({s}): {t}", .{ sym, err }); result.prices.put(sym, close) catch |err| log.warn("loadAllPrices cache-hit put({s}): {t}", .{ sym, err });
self.updateLatestDate(&result, sym); self.updateLatestDate(&result, sym);
@ -2283,7 +2267,7 @@ pub const DataService = struct {
// Offline mode: skip server sync and provider fetch entirely. // Offline mode: skip server sync and provider fetch entirely.
// For symbols without a fresh cache, fall back to stale cache // For symbols without a fresh cache, fall back to stale cache
// before giving up. // before giving up.
if (config.skip_network) { if (opts.skip_network) {
for (needs_fetch.items) |sym| { for (needs_fetch.items) |sym| {
if (self.getCachedLastClose(sym)) |close| { if (self.getCachedLastClose(sym)) |close| {
result.prices.put(sym, close) catch |err| log.warn("loadAllPrices cache-hit put({s}): {t}", .{ sym, err }); result.prices.put(sym, close) catch |err| log.warn("loadAllPrices cache-hit put({s}): {t}", .{ sym, err });
@ -2329,7 +2313,7 @@ pub const DataService = struct {
&result, &result,
symbol_progress, symbol_progress,
total_count - server_failures.items.len, // offset for progress display total_count - server_failures.items.len, // offset for progress display
config.fetchOptions(), opts,
); );
} }
@ -3572,23 +3556,6 @@ test "FetchOptions default is fully permissive" {
try std.testing.expect(!opts.force_refresh); try std.testing.expect(!opts.force_refresh);
} }
test "LoadAllConfig.fetchOptions maps fields through" {
const cfg = DataService.LoadAllConfig{
.force_refresh = true,
.skip_network = false,
};
const opts = cfg.fetchOptions();
try std.testing.expect(opts.force_refresh);
try std.testing.expect(!opts.skip_network);
const cfg2 = DataService.LoadAllConfig{
.skip_network = true,
};
const opts2 = cfg2.fetchOptions();
try std.testing.expect(opts2.skip_network);
try std.testing.expect(!opts2.force_refresh);
}
test "getCandles offline mode returns cached data without network" { test "getCandles offline mode returns cached data without network" {
const allocator = std.testing.allocator; const allocator = std.testing.allocator;
const io = std.testing.io; const io = std.testing.io;