model

package
v0.0.0-...-eb9deb1 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromTelegramMessage

func FromTelegramMessage(tgbotMsg tgbotapi.Message) (Message, User)

FromTelegramMessage creates an ORM compatible struct of a telegram message.

Types

type DataGroup

type DataGroup interface {
	Add(value interface{})
	UserGroup(tags []string) []User
	CheckTagExists(id int, tag string) bool
	CheckSubscribed(id int, tag string) bool
	UpdateTag(id int, tag string, flag string) error
	CountUsersAndMessages(period string) (int, int)
	GetMostUsedCommand(period string) string
}

For dependency injection

type Database

type Database struct {
	*gorm.DB
}

func InitializeDB

func InitializeDB() *Database

InitializeDB initializes DB

func (*Database) Add

func (db *Database) Add(value interface{})

func (*Database) CheckSubscribed

func (db *Database) CheckSubscribed(id int, tag string) bool

CheckSubscribed takes in an id and a tag and returns true if user is subscribed, false otherwise

func (*Database) CheckTagExists

func (db *Database) CheckTagExists(id int, tag string) bool

CheckTagExists takes in an id and a tag and returns whether the tag exists

func (*Database) CountUsersAndMessages

func (db *Database) CountUsersAndMessages(period string) (int, int)

Get number of users from database

func (*Database) GetMostUsedCommand

func (db *Database) GetMostUsedCommand(period string) string

function to get most used command

func (*Database) UpdateTag

func (db *Database) UpdateTag(id int, tag string, flag string) error

Update updates the flag for the tag for an User which is determined by the id

func (*Database) UserGroup

func (db *Database) UserGroup(tags []string) []User

UserGroup returns an array of User that is true for an array of tags

type Feedback

type Feedback struct {
	gorm.Model
	UserID     int
	MealType   string
	Stall      string
	Rating     string
	Additional string
	Date       int
}

structure to store feedback

func CreateFeedbackEntry

func CreateFeedbackEntry(tgbotMsg tgbotapi.Message) (Feedback, error)

type Message

type Message struct {
	gorm.Model
	MessageID int
	//User 	  User `gorm:"ForeignKey: UserID;AssociationForeignKey:UserID"`
	UserID int
	Text   string
	Date   int
}

Message is a struct that serializes the telegram message into a single row.

type User

type User struct {
	UserID     int `gorm:"primary_key"`
	CreatedAt  time.Time
	UpdatedAt  time.Time
	FirstName  string
	LastName   string
	UserName   string
	Everything string //`sql:"default:'false'"`
	Events     string //`sql:"default:'false'"`
	Food       string
	Warm       string
	Weather    string
}

User is an ORM compatible struct that serializes a telegram user's information.

Jump to

Keyboard shortcuts

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