MCPcopy Create free account
hub / github.com/aiprodcoder/MIXAPI / DeleteOldLog

Function DeleteOldLog

model/log.go:412–433  ·  view source on GitHub ↗
(ctx context.Context, targetTimestamp int64, limit int)

Source from the content-addressed store, hash-verified

410}
411
412func DeleteOldLog(ctx context.Context, targetTimestamp int64, limit int) (int64, error) {
413 var total int64 = 0
414
415 for {
416 if nil != ctx.Err() {
417 return total, ctx.Err()
418 }
419
420 result := LOG_DB.Where("created_at < ?", targetTimestamp).Limit(limit).Delete(&Log{})
421 if nil != result.Error {
422 return total, result.Error
423 }
424
425 total += result.RowsAffected
426
427 if result.RowsAffected < int64(limit) {
428 break
429 }
430 }
431
432 return total, nil
433}
434
435// DeleteLogsByTimeRange 根据时间范围删除日志
436func DeleteLogsByTimeRange(ctx context.Context, startTimestamp int64, endTimestamp int64, limit int) (int64, error) {

Callers

nothing calls this directly

Calls 1

DeleteMethod · 0.45

Tested by

no test coverage detected