Ver Fonte

chore: Fix duplicate code in executor when trying to reduce cyclo

jamesread há 5 meses atrás
pai
commit
a10088a040
1 ficheiros alterados com 0 adições e 44 exclusões
  1. 0 44
      service/internal/executor/executor.go

+ 0 - 44
service/internal/executor/executor.go

@@ -224,58 +224,14 @@ func (e *Executor) GetLogTrackingIds(startOffset int64, pageCount int64) ([]*Int
 	return trackingIds, pagingResult
 	return trackingIds, pagingResult
 }
 }
 
 
-// isValidLogEntryForACL checks if a log entry has all required fields for ACL checking.
 func isValidLogEntryForACL(entry *InternalLogEntry) bool {
 func isValidLogEntryForACL(entry *InternalLogEntry) bool {
 	return entry != nil && entry.Binding != nil && entry.Binding.Action != nil
 	return entry != nil && entry.Binding != nil && entry.Binding.Action != nil
 }
 }
 
 
-// isLogEntryAllowedByACL checks if a log entry is allowed to be viewed by the user.
 func isLogEntryAllowedByACL(cfg *config.Config, user *authpublic.AuthenticatedUser, entry *InternalLogEntry) bool {
 func isLogEntryAllowedByACL(cfg *config.Config, user *authpublic.AuthenticatedUser, entry *InternalLogEntry) bool {
 	return acl.IsAllowedLogs(cfg, user, entry.Binding.Action)
 	return acl.IsAllowedLogs(cfg, user, entry.Binding.Action)
 }
 }
 
 
-// parseDateFilter parses a date filter string and returns the parsed date and validity.
-func parseDateFilter(dateFilter string) (time.Time, bool) {
-	if dateFilter == "" {
-		return time.Time{}, false
-	}
-
-	parsedDate, err := time.Parse("2006-01-02", dateFilter)
-	if err != nil {
-		log.WithFields(log.Fields{
-			"dateFilter": dateFilter,
-			"error":      err,
-		}).Errorf("Failed to parse date filter, expected format YYYY-MM-DD")
-		return time.Time{}, false
-	}
-
-	return parsedDate, true
-}
-
-// matchesDateFilter checks if an entry matches the date filter criteria.
-func matchesDateFilter(entry *InternalLogEntry, filterDate time.Time, hasDateFilter bool) bool {
-	if !hasDateFilter {
-		return true
-	}
-
-	entryDate := entry.DatetimeStarted.UTC().Truncate(24 * time.Hour)
-	filterDateUTC := filterDate.UTC().Truncate(24 * time.Hour)
-	return entryDate.Equal(filterDateUTC)
-}
-
-// shouldIncludeLogEntry determines if a log entry should be included in filtered results.
-func shouldIncludeLogEntry(cfg *config.Config, user *authpublic.AuthenticatedUser, entry *InternalLogEntry, filterDate time.Time, hasDateFilter bool) bool {
-	if !isValidLogEntryForACL(entry) {
-		return false
-	}
-
-	if !isLogEntryAllowedByACL(cfg, user, entry) {
-		return false
-	}
-
-	return matchesDateFilter(entry, filterDate, hasDateFilter)
-}
-
 func (e *Executor) filterLogsByACL(cfg *config.Config, user *authpublic.AuthenticatedUser, dateFilter string) []*InternalLogEntry {
 func (e *Executor) filterLogsByACL(cfg *config.Config, user *authpublic.AuthenticatedUser, dateFilter string) []*InternalLogEntry {
 	e.logmutex.RLock()
 	e.logmutex.RLock()
 	defer e.logmutex.RUnlock()
 	defer e.logmutex.RUnlock()