mirror of
https://github.com/fankes/beszel.git
synced 2025-10-20 02:09:28 +08:00
allow creation of 10m record if nine 1m records
This commit is contained in:
@@ -19,10 +19,10 @@ type RecordManager struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type LongerRecordData struct {
|
type LongerRecordData struct {
|
||||||
shorterType string
|
shorterType string
|
||||||
longerType string
|
longerType string
|
||||||
longerTimeDuration time.Duration
|
longerTimeDuration time.Duration
|
||||||
expectedShorterRecords int
|
minShorterRecords int
|
||||||
}
|
}
|
||||||
|
|
||||||
type RecordDeletionData struct {
|
type RecordDeletionData struct {
|
||||||
@@ -39,28 +39,29 @@ func (rm *RecordManager) CreateLongerRecords() {
|
|||||||
// start := time.Now()
|
// start := time.Now()
|
||||||
recordData := []LongerRecordData{
|
recordData := []LongerRecordData{
|
||||||
{
|
{
|
||||||
shorterType: "1m",
|
shorterType: "1m",
|
||||||
expectedShorterRecords: 10,
|
// change to 9 from 10 to allow edge case timing or short pauses
|
||||||
longerType: "10m",
|
minShorterRecords: 9,
|
||||||
longerTimeDuration: -10 * time.Minute,
|
longerType: "10m",
|
||||||
|
longerTimeDuration: -10 * time.Minute,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
shorterType: "10m",
|
shorterType: "10m",
|
||||||
expectedShorterRecords: 2,
|
minShorterRecords: 2,
|
||||||
longerType: "20m",
|
longerType: "20m",
|
||||||
longerTimeDuration: -20 * time.Minute,
|
longerTimeDuration: -20 * time.Minute,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
shorterType: "20m",
|
shorterType: "20m",
|
||||||
expectedShorterRecords: 6,
|
minShorterRecords: 6,
|
||||||
longerType: "120m",
|
longerType: "120m",
|
||||||
longerTimeDuration: -120 * time.Minute,
|
longerTimeDuration: -120 * time.Minute,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
shorterType: "120m",
|
shorterType: "120m",
|
||||||
expectedShorterRecords: 4,
|
minShorterRecords: 4,
|
||||||
longerType: "480m",
|
longerType: "480m",
|
||||||
longerTimeDuration: -480 * time.Minute,
|
longerTimeDuration: -480 * time.Minute,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
// wrap the operations in a transaction
|
// wrap the operations in a transaction
|
||||||
@@ -111,7 +112,7 @@ func (rm *RecordManager) CreateLongerRecords() {
|
|||||||
)
|
)
|
||||||
|
|
||||||
// continue if not enough shorter records
|
// continue if not enough shorter records
|
||||||
if err != nil || len(allShorterRecords) < recordData.expectedShorterRecords {
|
if err != nil || len(allShorterRecords) < recordData.minShorterRecords {
|
||||||
// log.Println("not enough shorter records. continue.", len(allShorterRecords), recordData.expectedShorterRecords)
|
// log.Println("not enough shorter records. continue.", len(allShorterRecords), recordData.expectedShorterRecords)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user