add external id to .model

main
Bel LaPointe 2024-04-16 05:55:31 -06:00
parent a7d5d021d6
commit 0cecd5ea04
3 changed files with 16 additions and 14 deletions

View File

@ -2,8 +2,8 @@ package model
import "time" import "time"
// EVENT ||--|{ THREAD: "spawns"
type Event struct { type Event struct {
Updated uint64
ID string ID string
URL string URL string
TS uint64 TS uint64
@ -12,11 +12,11 @@ type Event struct {
Datacenter string Datacenter string
Team string Team string
Resolved bool Resolved bool
Updated uint64
} }
func NewEvent(ID, URL string, TS uint64, Name, Asset, Datacenter, Team string, Resolved bool) Event { func NewEvent(ID, URL string, TS uint64, Name, Asset, Datacenter, Team string, Resolved bool) Event {
return Event{ return Event{
Updated: updated(),
ID: ID, ID: ID,
URL: URL, URL: URL,
TS: TS, TS: TS,
@ -25,6 +25,9 @@ func NewEvent(ID, URL string, TS uint64, Name, Asset, Datacenter, Team string, R
Datacenter: Datacenter, Datacenter: Datacenter,
Team: Team, Team: Team,
Resolved: Resolved, Resolved: Resolved,
Updated: uint64(time.Now().UnixNano() / int64(time.Millisecond)),
} }
} }
func updated() uint64 {
return uint64(time.Now().UnixNano() / int64(time.Millisecond))
}

View File

@ -1,24 +1,24 @@
package model package model
import "time"
// THREAD ||--|{ MESSAGE: "populated by" // THREAD ||--|{ MESSAGE: "populated by"
type Message struct { type Message struct {
Updated uint64
ID string ID string
URL string URL string
TS uint64 TS uint64
Author string Author string
Plaintext string Plaintext string
Updated uint64 ThreadID string
} }
func NewMessage(ID, URL string, TS uint64, Author, Plaintext string) Message { func NewMessage(ID, URL string, TS uint64, Author, Plaintext string, ThreadID string) Message {
return Message{ return Message{
Updated: updated(),
ID: ID, ID: ID,
URL: URL, URL: URL,
TS: TS, TS: TS,
Author: Author, Author: Author,
Plaintext: Plaintext, Plaintext: Plaintext,
Updated: uint64(time.Now().UnixNano() / int64(time.Millisecond)), ThreadID: ThreadID,
} }
} }

View File

@ -1,23 +1,22 @@
package model package model
import "time"
// EVENT ||--|{ THREAD: "spawns" // EVENT ||--|{ THREAD: "spawns"
// THREAD ||--|{ MESSAGE: "populated by"
type Thread struct { type Thread struct {
Updated uint64
ID string ID string
URL string URL string
TS uint64 TS uint64
Channel string Channel string
Updated uint64 EventID string
} }
func NewThread(ID, URL string, TS uint64, Channel string) Thread { func NewThread(ID, URL string, TS uint64, Channel string, EventID string) Thread {
return Thread{ return Thread{
Updated: updated(),
ID: ID, ID: ID,
URL: URL, URL: URL,
TS: TS, TS: TS,
Channel: Channel, Channel: Channel,
Updated: uint64(time.Now().UnixNano() / int64(time.Millisecond)), EventID: EventID,
} }
} }