mirror of
https://github.com/ddworken/hishtory.git
synced 2025-04-01 03:47:52 +02:00
Optimize server by only sending new-ish records to the client
This commit is contained in:
parent
a65fbb7192
commit
2b676a935b
@ -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)
|
GLOBAL_DB.Exec("UPDATE enc_history_entries SET read_count = read_count + 1 WHERE device_id = ?", deviceId)
|
||||||
|
|
||||||
// Then retrieve, to avoid a race condition
|
// 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
|
var historyEntries []*shared.EncHistoryEntry
|
||||||
result := tx.Find(&historyEntries)
|
result := tx.Find(&historyEntries)
|
||||||
if result.Error != nil {
|
if result.Error != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user