yats.git

ref: f79a9d09c451653ff27fb34afb5b0c71dc758a32

server/db/event.go


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
package db

import (
	"fmt"
	"time"
)

func SaveEvent(idClient string, eventName string) {
	q := fmt.Sprintf("insert into event ( id_client, etime, name) values ('%s',toTimestamp(now()),'%s');", idClient, eventName)
	fmt.Printf("q=%s", q)
	Session.Query(q).Exec()
}

func SaveEventAt(idClient string, tstamp time.Time, eventName string) {
	timeAsBytes, _ := tstamp.UTC().MarshalText()
	q := fmt.Sprintf("insert into event ( id_client, etime, name) values ('%s','%s','%s');", idClient, string(timeAsBytes), eventName)
	Session.Query(q).Exec()
}