(start, stop time.Time, interval, retention time.Duration, r *rand.Rand)
| 455 | } |
| 456 | |
| 457 | func selectPastTimestamp(start, stop time.Time, interval, retention time.Duration, r *rand.Rand) (newStart, ts time.Time) { |
| 458 | oldest := stop.Add(-retention) |
| 459 | |
| 460 | if oldest.After(start) { |
| 461 | newStart = oldest |
| 462 | } else { |
| 463 | newStart = start |
| 464 | } |
| 465 | |
| 466 | ts = time.Unix(generateRandomInt(newStart.Unix(), stop.Unix(), r), 0) |
| 467 | |
| 468 | return newStart.Round(interval), ts.Round(interval) |
| 469 | } |
| 470 | |
| 471 | func generateRandomInt(minVal, maxVal int64, r *rand.Rand) int64 { |
| 472 | minVal++ |
no test coverage detected