(ctx context.Context)
| 236 | } |
| 237 | |
| 238 | func 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 | |
| 255 | func GoRecordTEventWrap(tevent *telemetrydata.TEvent) { |
| 256 | if tevent == nil || tevent.Event == "" { |
no test coverage detected