MCPcopy
hub / github.com/wavetermdev/waveterm / CleanOldTEvents

Function CleanOldTEvents

pkg/telemetry/telemetry.go:307–318  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

305}
306
307func CleanOldTEvents(ctx context.Context) error {
308 daysToKeep := 7
309 if !IsTelemetryEnabled() {
310 daysToKeep = 1
311 }
312 olderThan := time.Now().AddDate(0, 0, -daysToKeep).UnixMilli()
313 return wstore.WithTx(ctx, func(tx *wstore.TxWrap) error {
314 query := `DELETE FROM db_tevent WHERE ts < ?`
315 tx.Exec(query, olderThan)
316 return nil
317 })
318}
319
320func GetNonUploadedTEvents(ctx context.Context, maxEvents int) ([]*telemetrydata.TEvent, error) {
321 now := time.Now()

Callers 1

SendAllTelemetryFunction · 0.92

Calls 2

WithTxFunction · 0.92
IsTelemetryEnabledFunction · 0.85

Tested by

no test coverage detected