From 2b676a935b60c4f602fe7882a4120c15dac2a8df Mon Sep 17 00:00:00 2001 From: David Dworken Date: Sat, 16 Apr 2022 10:30:39 -0700 Subject: [PATCH] Optimize server by only sending new-ish records to the client --- backend/server/server.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/server/server.go b/backend/server/server.go index fd34ce2..3384278 100644 --- a/backend/server/server.go +++ b/backend/server/server.go @@ -66,7 +66,7 @@ func apiEQueryHandler(w http.ResponseWriter, r *http.Request) { GLOBAL_DB.Exec("UPDATE enc_history_entries SET read_count = read_count + 1 WHERE device_id = ?", deviceId) // Then retrieve, to avoid a race condition - tx := GLOBAL_DB.Where("device_id = ?", deviceId) + tx := GLOBAL_DB.Where("device_id = ? AND read_count < 5", deviceId) var historyEntries []*shared.EncHistoryEntry result := tx.Find(&historyEntries) if result.Error != nil {