datastore

package
v0.0.0-...-5eac97b Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2020 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connect

func Connect(cfg c.Config)

Connect uses the configuration passed from the config file to connect to Postgres and ensure that the table is created properly.

func CreateActivitiesTable

func CreateActivitiesTable()

CreateActivitiesTable checks to see if the proper table exists, and if it doesn't, create one.

func CreateChannelsTable

func CreateChannelsTable()

CreateChannelsTable checks to see if the proper table exists, and if it doesn't, create one.

func CreateTagsTable

func CreateTagsTable()

CreateTagsTable checks to see if the proper table exists, and if it doesn't, create one.

func CreateTriagerTable

func CreateTriagerTable()

CreateTriagerTable checks to see if the proper table exists, and if it doesn't, create one.

func DeleteTag

func DeleteTag(data string) error

DeleteTag removes the tag located at the ID

func LoadChannel

func LoadChannel(channelID string) (channel string, err error)

func LoadChannels

func LoadChannels(dm bool) (channels []string, err error)

LoadChannels grabs the list of channels from the database and returns them in a slice of strings.

func LoadTag

func LoadTag(id int) (loadedTag map[string]interface{})

LoadTag takes an id and loads a single tag's information from the database

func LoadTags

func LoadTags() (tags []map[string]interface{})

LoadTags retrieves all of the tags from the database, either to list or to loop through

func LoadTriager

func LoadTriager() (triager string, err error)

LoadTriager requests the triager with the most recent updated_at value in the table

func SaveActivity

func SaveActivity(user string, name string, activityType string) error

SaveActivity takes the user data and activity type and saves it to the Postgres database

func SaveChannels

func SaveChannels(channelID string, private bool) (err error)

SaveChannels saves channels into the database and updates the existing record if one exists

func SaveNewTag

func SaveNewTag(data map[string]string) error

SaveNewTag saves a new tag into the database

func SaveTagUpdate

func SaveTagUpdate(data map[string]string) error

SaveTagUpdate saves a tag update into the database

func SaveTriager

func SaveTriager(data string) error

SaveTriager saves a new triager into the database

Types

type Activity

type Activity struct {
	SlackID      string
	SlackName    string
	ActivityType string
	StartedAt    NullTime
	EndedAt      NullTime
}

Activity represents a single activity listed in the database

func LoadActivity

func LoadActivity(opts ActivityOptions) (activities []Activity, err error)

LoadActivity requests a list of activity/activities from the database to use in the History command, or in reporting

type ActivityOptions

type ActivityOptions struct {
	ActivityType string
	Quantity     int
}

ActivityOptions allows us to pass multiple optional parameters to the LoadActivity function, including a filter for activityType and a cap on how many are loaded

type NullTime

type NullTime struct {
	Time  time.Time
	Valid bool // Valid is true if Time is not NULL
}

func (*NullTime) Scan

func (nt *NullTime) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullTime) Value

func (nt NullTime) Value() (driver.Value, error)

Value implements the driver Valuer interface.

Jump to

Keyboard shortcuts

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