Optimize server by only sending new-ish records to the client

This commit is contained in:
David Dworken 2022-04-16 10:30:39 -07:00
parent a65fbb7192
commit 2b676a935b

View File

@ -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 {