import 'focus_session.dart';

class HistoryRepository {
  static final List<FocusSession> _sessions = [
    FocusSession(
      startTime: DateTime.now().subtract(const Duration(hours: 1)),
      durationMinutes: 45,
      tag: "Deep Work",
      intent: "Project Architecture",
      rating: 5.0,
    ),
    FocusSession(
      startTime: DateTime.now().subtract(const Duration(days: 1, hours: 2)),
      durationMinutes: 25,
      tag: "Reading",
      intent: "Design Patterns",
      rating: 4.0,
    ),
    FocusSession(
      startTime: DateTime.now().subtract(const Duration(days: 1, hours: 4)),
      durationMinutes: 25,
      tag: "Deep Work",
      intent: null,
      rating: 5.0,
    ),
    FocusSession(
      startTime: DateTime.now().subtract(const Duration(days: 2)),
      durationMinutes: 60,
      tag: "Creation",
      intent: "Video Editing",
      rating: 3.0,
    ),
  ];

  static List<FocusSession> get sessions => List.unmodifiable(_sessions);

  static void addSession(FocusSession session) {
    _sessions.insert(0, session);
  }

  static int get todayMinutes {
    final now = DateTime.now();
    return _sessions
        .where((s) =>
            s.startTime.year == now.year &&
            s.startTime.month == now.month &&
            s.startTime.day == now.day)
        .fold(0, (sum, s) => sum + s.durationMinutes);
  }

  static int get currentStreak {
    return 3;
  }
}
