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(
syms,
watch_syms_list.items,
.{
.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.fetch_options,
opts.aggregate_progress,
sym_cb,
);

View file

@ -295,7 +295,7 @@ pub fn loadPortfolioPrices(
.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).
// .auto -> respect TTL, fetch on stale.
// .never -> offline mode: never touch the network. Stale cache
@ -303,11 +303,7 @@ pub fn loadPortfolioPrices(
const result = svc.loadAllPrices(
portfolio_syms,
watch_syms,
.{
.force_refresh = refresh == .force,
.skip_network = refresh == .never,
.color = color,
},
fetchOptionsFromPolicy(refresh),
aggregate.callback(),
symbol_progress.callback(),
);

View file

@ -2122,22 +2122,6 @@ pub const DataService = struct {
// Consolidated Price Loading (Parallel Server + Sequential Provider)
/// 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.
pub const LoadAllResult = struct {
prices: std.StringHashMap(f64),
@ -2217,7 +2201,7 @@ pub const DataService = struct {
self: *DataService,
portfolio_syms: ?[]const []const u8,
watch_syms: []const []const u8,
config: LoadAllConfig,
opts: FetchOptions,
aggregate_progress: ?AggregateProgressCallback,
symbol_progress: ?ProgressCallback,
) 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 });
// 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
// `--refresh-data=force` contract. The Phase-1 fast path below
// 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);
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| {
result.prices.put(sym, close) catch |err| log.warn("loadAllPrices cache-hit put({s}): {t}", .{ sym, err });
self.updateLatestDate(&result, sym);
@ -2283,7 +2267,7 @@ pub const DataService = struct {
// Offline mode: skip server sync and provider fetch entirely.
// For symbols without a fresh cache, fall back to stale cache
// before giving up.
if (config.skip_network) {
if (opts.skip_network) {
for (needs_fetch.items) |sym| {
if (self.getCachedLastClose(sym)) |close| {
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,
symbol_progress,
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);
}
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" {
const allocator = std.testing.allocator;
const io = std.testing.io;