Nityananda Gohain 90b5f88413
feat: logs list API, logic update for better perf (#5912)
* feat: logsV4 initial refactoring

* feat: filter_query builder with tests added

* feat: all functions of v4 refactored

* fix: tests fixed

* feat: logs list API, logic update for better perf

* fix: update select for table panel

* fix: tests updated with better examples of limit and group by

* fix: resource filter support in live tail

* feat: cleanup and use flag

* feat: restrict new list api to single query

* fix: move getTsRanges to utils
2024-09-12 21:34:27 +05:30

39 lines
725 B
Go

package utils
const HOUR_NANO = int64(3600000000000)
type LogsListTsRange struct {
Start int64
End int64
}
func GetLogsListTsRanges(start, end int64) []LogsListTsRange {
startNano := GetEpochNanoSecs(start)
endNano := GetEpochNanoSecs(end)
result := []LogsListTsRange{}
if endNano-startNano > HOUR_NANO {
bucket := HOUR_NANO
tStartNano := endNano - bucket
complete := false
for {
result = append(result, LogsListTsRange{Start: tStartNano, End: endNano})
if complete {
break
}
bucket = bucket * 2
endNano = tStartNano
tStartNano = tStartNano - bucket
// break condition
if tStartNano <= startNano {
complete = true
tStartNano = startNano
}
}
}
return result
}