Monorepo for Tangled tangled.org

knotserver: switch timestamps to unix nanos

Signed-off-by: oppiliappan <me@oppi.li>

oppi.li 95c3f149 fe8c96f0

verified
Changed files
+8 -2
knotserver
+3 -1
knotserver/db/events.go
··· 2 3 import ( 4 "fmt" 5 6 "tangled.sh/tangled.sh/core/notifier" 7 ) ··· 16 func (d *DB) InsertEvent(event Event, notifier *notifier.Notifier) error { 17 18 _, err := d.db.Exec( 19 - `insert into events (rkey, nsid, event) values (?, ?, ?)`, 20 event.Rkey, 21 event.Nsid, 22 event.EventJson, 23 ) 24 25 notifier.NotifyAll()
··· 2 3 import ( 4 "fmt" 5 + "time" 6 7 "tangled.sh/tangled.sh/core/notifier" 8 ) ··· 17 func (d *DB) InsertEvent(event Event, notifier *notifier.Notifier) error { 18 19 _, err := d.db.Exec( 20 + `insert into events (rkey, nsid, event, created) values (?, ?, ?, ?)`, 21 event.Rkey, 22 event.Nsid, 23 event.EventJson, 24 + time.Now().UnixNano(), 25 ) 26 27 notifier.NotifyAll()
+5 -1
knotserver/events.go
··· 43 } 44 }() 45 46 cursorStr := r.URL.Query().Get("cursor") 47 cursor, err := strconv.ParseInt(cursorStr, 10, 64) 48 if err != nil { 49 - l.Error("empty or invalid cursor, defaulting to zero", "invalidCursor", cursorStr) 50 } 51 52 // complete backfill first before going to live data
··· 43 } 44 }() 45 46 + defaultCursor := time.Now().UnixNano() 47 cursorStr := r.URL.Query().Get("cursor") 48 cursor, err := strconv.ParseInt(cursorStr, 10, 64) 49 if err != nil { 50 + l.Error("empty or invalid cursor", "invalidCursor", cursorStr, "default", defaultCursor) 51 + } 52 + if cursor == 0 { 53 + cursor = defaultCursor 54 } 55 56 // complete backfill first before going to live data