Mirror of @tangled.org/core. Running on a Raspberry Pi Zero 2 (Please be gentle).
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

knotserver: switch timestamps to unix nanos

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

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