storage

package
v0.0.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 29, 2017 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Sql

type Sql struct {
	Db *sql.DB
}

func NewSql

func NewSql(conDsn string) (s *Sql, err error)

func (*Sql) AddRawLineEvent

func (s *Sql) AddRawLineEvent(eventType, rawevent string) error

func (*Sql) AddUserProfile

func (s *Sql) AddUserProfile(userID, displayName string) error

AddUserProfile adds a user profile if the user already exists in the table this method does nothing

func (*Sql) Close

func (s *Sql) Close() error

func (*Sql) GetGpsAnswerData

func (s *Sql) GetGpsAnswerData() (answerGpsData []UserGpsAnswerData, err error)

func (*Sql) GetQuestions

func (s *Sql) GetQuestions() (qs *domain.Questions, err error)

func (*Sql) GetUserAnswerData

func (s *Sql) GetUserAnswerData() (answerData []UserAnswerData, err error)

func (*Sql) GetUserProfile

func (s *Sql) GetUserProfile(userId string) (profile domain.UserProfile, err error)

func (*Sql) GetUsersWithoutAnswers

func (s *Sql) GetUsersWithoutAnswers(delaySecs int64) (userIds []string, err error)

func (*Sql) GetWelcomeMsgs

func (s *Sql) GetWelcomeMsgs(tplVars *WelcomeMsgTplVars) (msgs []string, err error)

func (*Sql) MarkProfileBotSurveyInited

func (s *Sql) MarkProfileBotSurveyInited(userId string) error

func (*Sql) UserAddAnswer

func (s *Sql) UserAddAnswer(answer domain.Answer) error

func (*Sql) UserAddGpsAnswer

func (s *Sql) UserAddGpsAnswer(answer domain.AnswerGps) error

func (*Sql) UserGetLastAnswer

func (s *Sql) UserGetLastAnswer(uid string) (domain.Answer, error)

func (*Sql) UserHasAnswers

func (s *Sql) UserHasAnswers(userId string) (bool, error)

func (*Sql) WipeUser

func (s *Sql) WipeUser(userId string) error

type Storage

type Storage interface {
	// used for after-the-fact debugging
	AddRawLineEvent(eventType, rawMsg string) error
	GetUserProfile(userId string) (domain.UserProfile, error)
	MarkProfileBotSurveyInited(userId string) error
	GetUsersWithoutAnswers(sinceUnixTs int64) (userIds []string, err error)
	GetUserAnswerData() ([]UserAnswerData, error)
	GetGpsAnswerData() ([]UserGpsAnswerData, error)
	AddUserProfile(userId, displayName string) error
	UserHasAnswers(userId string) (bool, error)
	UserGetLastAnswer(userId string) (domain.Answer, error)
	UserAddAnswer(domain.Answer) error
	UserAddGpsAnswer(domain.AnswerGps) error
	GetQuestions() (*domain.Questions, error)
	GetWelcomeMsgs(tplVars *WelcomeMsgTplVars) ([]string, error)
	WipeUser(userId string) error
	// cleanup any connection / file descriptors to the storage
	Close() error
}

type UserAnswerData

type UserAnswerData struct {
	// @TODO embed domain.Answer
	// domain.Answer
	Id         uint
	UserId     string
	QuestionId string
	Answer     string
	Channel    string
	Timestamp  int
}

type UserGpsAnswerData

type UserGpsAnswerData struct {
	Id        uint
	UserId    string
	Address   string
	Lat       float64
	Lon       float64
	Timestamp int
	Channel   string
}

type WelcomeMsgTplVars

type WelcomeMsgTplVars struct {
	UserId   string
	Hostname string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL