Revert "Add preliminary support for persisting pre-saved history entries remotely"

This reverts commit ff98a7907c. That commit is incomplete since it doesn't include support for the continous deletion of pre-saved history entries as soon as they
finish running. Support for this will require a good bit more work/thought, so reverting for and keeping this code in the git history.
This commit is contained in:
David Dworken
2023-09-21 12:39:20 -07:00
parent ff98a7907c
commit 66916c27cb
8 changed files with 42 additions and 76 deletions

View File

@@ -600,10 +600,7 @@ func ProcessDeletionRequests(ctx context.Context) error {
db := hctx.GetDb(ctx)
for _, request := range deletionRequests {
for _, entry := range request.Messages.Ids {
// Note that entry.StartTime is not always present (for legacy reasons) and entry.EndTime is also
// not always present (for pre-saved entries). So we just check that one of them matches.
tx := db.Where("device_id = ? AND (start_time = ? OR end_time = ?)", entry.DeviceId, entry.StartTime, entry.EndTime)
res := tx.Delete(&data.HistoryEntry{})
res := db.Where("device_id = ? AND end_time = ?", entry.DeviceId, entry.Date).Delete(&data.HistoryEntry{})
if res.Error != nil {
return fmt.Errorf("DB error: %w", res.Error)
}