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

Function TruncateActivityTEventForShutdown

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

Source from the content-addressed store, hash-verified

236}
237
238func TruncateActivityTEventForShutdown(ctx context.Context) error {
239 nowTs := time.Now()
240 eventTs := nowTs.Truncate(time.Hour).Add(time.Hour)
241 return wstore.WithTx(ctx, func(tx *wstore.TxWrap) error {
242 // find event that matches this timestamp with event name "app:activity"
243 uuidStr := tx.GetString(`SELECT uuid FROM db_tevent WHERE ts = ? AND event = ?`, eventTs.UnixMilli(), ActivityEventName)
244 if uuidStr == "" {
245 return nil
246 }
247 // we're going to update this app:activity event back to nowTs
248 tsLocal := utilfn.ConvertToWallClockPT(nowTs).Format(time.RFC3339)
249 query := `UPDATE db_tevent SET ts = ?, tslocal = ? WHERE uuid = ?`
250 tx.Exec(query, nowTs.UnixMilli(), tsLocal, uuidStr)
251 return nil
252 })
253}
254
255func GoRecordTEventWrap(tevent *telemetrydata.TEvent) {
256 if tevent == nil || tevent.Event == "" {

Callers 1

shutdownActivityUpdateFunction · 0.92

Calls 3

WithTxFunction · 0.92
ConvertToWallClockPTFunction · 0.92
GetStringMethod · 0.80

Tested by

no test coverage detected