Add client-side summary calculation and lookup resolution from cache

- Add calculateSummaryFromKanban() to compute summary stats from cached kanban data
- Add refreshSummaryFromKanban() called after task CRUD operations
- Fix column name matching to use API format (e.g., "overdue_tasks" not "overdue")
- Fix tasksDueNextMonth to only include due_soon tasks (not upcoming)
- Update TaskResponse computed properties to resolve from DataManager cache
- Update iOS task cards to use computed properties for priority/frequency/category
- This enables API to skip preloading lookups for better performance

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Trey t
2025-12-14 01:04:52 -06:00
parent 4592c4493c
commit e2d264da7e
7 changed files with 85 additions and 18 deletions

View File

@@ -273,10 +273,10 @@ final class WidgetDataManager {
id: Int(task.id),
title: task.title,
description: task.description_,
priority: task.priority?.name ?? "",
priority: task.priorityName ?? "",
inProgress: task.inProgress,
dueDate: task.effectiveDueDate, // Use effective date (nextDueDate if set, otherwise dueDate)
category: task.category?.name ?? "",
category: task.categoryName ?? "",
residenceName: "", // No longer available in API, residence lookup needed
isOverdue: column.name == "overdue_tasks"
)

View File

@@ -483,7 +483,8 @@ private extension ResidenceDetailView {
Task {
do {
let result = try await APILayer.shared.getContractorsByResidence(
residenceId: Int32(Int(residenceId))
residenceId: Int32(Int(residenceId)),
forceRefresh: false
)
await MainActor.run {

View File

@@ -16,7 +16,7 @@ struct DynamicTaskCard: View {
@State private var showCompletionHistory = false
var body: some View {
let _ = print("📋 DynamicTaskCard - Task: \(task.title), ButtonTypes: \(buttonTypes)")
// let _ = print("📋 DynamicTaskCard - Task: \(task.title), ButtonTypes: \(buttonTypes)")
VStack(alignment: .leading, spacing: 12) {
HStack {
@@ -32,7 +32,7 @@ struct DynamicTaskCard: View {
Spacer()
PriorityBadge(priority: task.priority?.name ?? "")
PriorityBadge(priority: task.priorityName ?? "")
}
if !task.description_.isEmpty {
@@ -43,7 +43,7 @@ struct DynamicTaskCard: View {
}
HStack {
Label(task.frequency?.displayName ?? "", systemImage: "repeat")
Label(task.frequencyDisplayName ?? "", systemImage: "repeat")
.font(.caption)
.foregroundColor(Color.appTextSecondary)

View File

@@ -30,7 +30,7 @@ struct TaskCard: View {
Spacer()
PriorityBadge(priority: task.priority?.name ?? "")
PriorityBadge(priority: task.priorityName ?? "")
}
// Description
@@ -47,7 +47,7 @@ struct TaskCard: View {
Image(systemName: "repeat")
.font(.system(size: 12, weight: .medium))
.foregroundColor(Color.appTextSecondary.opacity(0.7))
Text(task.frequency?.displayName ?? "")
Text(task.frequencyDisplayName ?? "")
.font(.caption.weight(.medium))
.foregroundColor(Color.appTextSecondary)
}

View File

@@ -33,7 +33,7 @@ struct CompleteTaskView: View {
.font(.headline)
HStack {
Label((task.category?.name ?? "").capitalized, systemImage: "folder")
Label((task.categoryName ?? "").capitalized, systemImage: "folder")
.font(.subheadline)
.foregroundStyle(.secondary)