searchLogs method

List<Map<String, dynamic>> searchLogs({
  1. String? action,
  2. String? navigationType,
  3. String? fromPage,
  4. String? toPage,
  5. DateTime? startTime,
  6. DateTime? endTime,
})

搜索导航日志

Implementation

List<Map<String, dynamic>> searchLogs({
  String? action,
  String? navigationType,
  String? fromPage,
  String? toPage,
  DateTime? startTime,
  DateTime? endTime,
}) {
  return _navigationLogs.where((log) {
    if (action != null && log['action'] != action) return false;
    if (navigationType != null && log['navigationType'] != navigationType) return false;
    if (fromPage != null && log['fromPage'] != fromPage) return false;
    if (toPage != null && log['toPage'] != toPage) return false;

    if (startTime != null || endTime != null) {
      final timestamp = log['timestamp'] as int;
      final logTime = DateTime.fromMillisecondsSinceEpoch(timestamp);

      if (startTime != null && logTime.isBefore(startTime)) return false;
      if (endTime != null && logTime.isAfter(endTime)) return false;
    }

    return true;
  }).toList();
}