fix(programmer-tasks): tab switching + help-given live data
Tab switching: _buildTabs was recreating TabController on every build because `_tabs == tabs` compares List by reference identity, not content. programmerTasksTabsFor() always returns a new list, so the guard was always false, resetting the controller to initialIndex 0 on every tap. Fixed by using listEquals from flutter/foundation. Help given: computeProgrammerStats accumulated helpGivenThisMonth only from approvedSnapshot rows, which only exist after admin approval. Programmers who helped others but had pending sheets saw 0m indefinitely. Fixed by adding helpGivenThisMonthProvider (FutureProvider.family) that queries programmer_task_work_logs directly for the current Manila month, and passing it as liveHelpThisMonthSec to computeProgrammerStats. Co-Authored-By: claude-flow <ruv@ruv.net>
This commit is contained in:
@@ -200,6 +200,35 @@ final programmerDayDataProvider =
|
||||
return fetchDayActivityData(client, day: day, tasks: tasks, now: AppTime.now());
|
||||
});
|
||||
|
||||
/// Total help-given seconds for [userId] in the current Manila calendar month.
|
||||
///
|
||||
/// Queries work logs with minutes > 0 authored by [userId] this month.
|
||||
/// Re-fetches whenever [programmerActivitySignalProvider] fires.
|
||||
final helpGivenThisMonthProvider =
|
||||
FutureProvider.family<int, String>((ref, userId) async {
|
||||
ref.watch(programmerActivitySignalProvider);
|
||||
final client = ref.watch(supabaseClientProvider);
|
||||
final today = ref.watch(todayKeyProvider);
|
||||
final monthStart = DateTime.utc(today.year, today.month, 1);
|
||||
final nextMonthStart = today.month < 12
|
||||
? DateTime.utc(today.year, today.month + 1, 1)
|
||||
: DateTime.utc(today.year + 1, 1, 1);
|
||||
|
||||
final raw = await client
|
||||
.from('programmer_task_work_logs')
|
||||
.select('minutes')
|
||||
.eq('author_id', userId)
|
||||
.gte('work_date', formatDayKey(monthStart))
|
||||
.lt('work_date', formatDayKey(nextMonthStart)) as List;
|
||||
|
||||
int totalSec = 0;
|
||||
for (final r in raw) {
|
||||
final minutes = r['minutes'] as int?;
|
||||
if (minutes != null && minutes > 0) totalSec += minutes * 60;
|
||||
}
|
||||
return totalSec;
|
||||
});
|
||||
|
||||
/// Run states for today's tasks, derived from today's [programmerDayDataProvider].
|
||||
final programmerRunStatesProvider = Provider<Map<String, ProgrammerRunInfo>>((ref) {
|
||||
final today = ref.watch(todayKeyProvider);
|
||||
|
||||
Reference in New Issue
Block a user