models

package
v0.0.0-...-c7ad020 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2019 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const Key = "fkzfgk0FY2CaYJhyXbshnPJaRrFtCwfj"

Variables

This section is empty.

Functions

func CreateInitialCategories

func CreateInitialCategories(db *gorm.DB) error

CreateInitialCategories ...

func CreateWeight

func CreateWeight(ctx context.Context, in *qpb.CreateQuestionRequest, db *gorm.DB, answer Answer) ([5]byte, error)

CreateWeight ...

func Decrypt

func Decrypt(cryptoText string) map[string]string

Decrypt ...

func GetEmail

func GetEmail(authToken string) string

GetEmail from authToken

func GetLevel

func GetLevel(category *Category, db *gorm.DB) int32

GetLevel ...

func GetPersonalityScore

func GetPersonalityScore(user User, answer Answer, option int32, db *gorm.DB) (float32, error)

GetPersonalityScore ...

func GetWeightRange

func GetWeightRange(category *Category, db *gorm.DB) string

GetWeightRange ...

func RegisterAnswer

func RegisterAnswer(answer Answer, user User, in *pb.GetQuestionRequest, db *gorm.DB) (int32, error)

RegisterAnswer ...

func SetupDatabase

func SetupDatabase(db *gorm.DB) error

SetupDatabase - Creates the tables in the database

func WeightRange

func WeightRange(questions []Question) string

WeightRange ...

Types

type Answer

type Answer struct {
	gorm.Model
	UserID      uint
	QuestionID  uint
	Weights     []byte `gorm:"type=bytea"`
	Categories  []byte `gorm:"type=bytea"`
	Option1     string `json:"Option1"`
	Option2     string `json:"Option2"`
	Option3     string `json:"Option3"`
	Option4     string `json:"Option4"`
	Option5     string `json:"Option5"`
	UsersAnswer UsersAnswer
}

Answer is a gorm model

type Category

type Category struct {
	gorm.Model
	Questions []Question
	Name      string
	Parent    uint
	Level     int32
	Approved  bool
	Option    int32 `gorm:"-"` // ignore this field
}

Category is a gorm model

type Question

type Question struct {
	gorm.Model
	Title      string
	Body       string
	Answer     Answer
	Weight     Weight
	Approved   bool
	CategoryID uint
	UserID     uint
}

Question is a gorm model

func (Question) CreateInDB

func (question Question) CreateInDB(ctx context.Context, in *qpb.CreateQuestionRequest, db *gorm.DB) (*qpb.CreateQuestionResponse, error)

CreateInDB question and return response

func (Question) GetFromDB

func (question Question) GetFromDB(ctx context.Context, in *qpb.GetQuestionRequest, db *gorm.DB) (*qpb.GetQuestionResponse, error)

GetFromDB question in response to the previous question

type User

type User struct {
	gorm.Model
	Email       string `validate:"required"`
	Questions   []Question
	Answers     []Answer
	UsersAnswer UsersAnswer
	Score       float32
}

User is a gorm model

func CreateUser

func CreateUser(email string, db *gorm.DB) (User, error)

CreateUser ...

func (User) ApproveEntries

func (user User) ApproveEntries(ctx context.Context, in *upb.ApproveEntriesRequest, db *gorm.DB) (*upb.ApproveEntriesResponse, error)

ApproveEntries ...

func (User) GetEntries

func (user User) GetEntries(ctx context.Context, in *upb.GetEntriesRequest, db *gorm.DB) (*upb.GetEntriesResponse, error)

GetEntries ...

type UsersAnswer

type UsersAnswer struct {
	gorm.Model
	UserID   uint
	AnswerID uint
	Option   int32
}

UsersAnswer is a gorm model

type Weight

type Weight struct {
	gorm.Model
	QuestionID sql.NullInt64
	AnswerID   sql.NullInt64
	Value      float32
	Option     int32
}

Weight is a gorm model

Jump to

Keyboard shortcuts

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