Refactor data sources and feed model

This commit is contained in:
2026-01-10 00:25:36 +00:00
parent 1e65a3f57d
commit 324b35a464
15 changed files with 631 additions and 609 deletions

View File

@@ -45,18 +45,48 @@ struct OrchestratorView: View {
Button("Recompute Now") { orchestrator.recomputeNow() }
}
Section("Winner") {
if let env = orchestrator.lastWinner {
Text(env.winner.title)
Section("Feed") {
if let feed = orchestrator.lastFeed, let winner = feed.winnerItem() {
Text(winner.title)
.font(.headline)
Text(env.winner.subtitle)
.font(.subheadline)
.foregroundStyle(.secondary)
Text("type \(env.winner.type.rawValue) • prio \(String(format: "%.2f", env.winner.priority)) • ttl \(env.winner.ttlSec)s")
if !winner.subtitle.isEmpty {
Text(winner.subtitle)
.font(.subheadline)
.foregroundStyle(.secondary)
}
Text("type \(winner.type.rawValue) • prio \(String(format: "%.2f", winner.priority)) • ttl \(winner.ttlSec)s")
.font(.caption)
.foregroundStyle(.secondary)
if feed.feed.count > 1 {
Divider()
}
ForEach(feed.feed, id: \.id) { item in
VStack(alignment: .leading, spacing: 6) {
HStack {
Text(item.title)
.font(.headline)
.lineLimit(1)
Spacer()
Text(item.type.rawValue)
.font(.caption)
.foregroundStyle(.secondary)
}
if !item.subtitle.isEmpty {
Text(item.subtitle)
.font(.subheadline)
.foregroundStyle(.secondary)
.lineLimit(1)
}
Text("bucket \(item.bucket.rawValue) • prio \(String(format: "%.2f", item.priority)) • ttl \(item.ttlSec)s")
.font(.caption)
.foregroundStyle(.secondary)
}
.padding(.vertical, 4)
}
} else {
Text("No winner yet")
Text("No feed yet")
.foregroundStyle(.secondary)
}
}
@@ -80,35 +110,6 @@ struct OrchestratorView: View {
}
}
Section("Candidates (\(orchestrator.lastCandidates.count))") {
if orchestrator.lastCandidates.isEmpty {
Text("No candidates")
.foregroundStyle(.secondary)
} else {
ForEach(orchestrator.lastCandidates, id: \.id) { c in
VStack(alignment: .leading, spacing: 6) {
HStack {
Text(c.title)
.font(.headline)
.lineLimit(1)
Spacer()
Text(c.type.rawValue)
.font(.caption)
.foregroundStyle(.secondary)
}
Text(c.subtitle)
.font(.subheadline)
.foregroundStyle(.secondary)
.lineLimit(1)
Text("conf \(String(format: "%.2f", c.confidence)) • ttl \(c.ttlSec)s")
.font(.caption)
.foregroundStyle(.secondary)
}
.padding(.vertical, 4)
}
}
}
if !orchestrator.lastWeatherDiagnostics.isEmpty {
Section("Weather Diagnostics") {
ForEach(orchestrator.lastWeatherDiagnostics.keys.sorted(), id: \.self) { key in
@@ -122,6 +123,19 @@ struct OrchestratorView: View {
}
}
if !orchestrator.lastCalendarDiagnostics.isEmpty {
Section("Calendar Diagnostics") {
ForEach(orchestrator.lastCalendarDiagnostics.keys.sorted(), id: \.self) { key in
LabeledContent(key) {
Text(orchestrator.lastCalendarDiagnostics[key] ?? "")
.font(.caption)
.foregroundStyle(.secondary)
.textSelection(.enabled)
}
}
}
}
Section("Test") {
Button("Send Fixture Feed Now") { orchestrator.sendFixtureFeedNow() }
}