database

package
v0.0.0-...-0ad4d90 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2024 License: Apache-2.0 Imports: 21 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DB *gorm.DB
View Source
var Redis *redis.Client

Functions

func AddDelayedJob

func AddDelayedJob(queue, body string, duration time.Duration) error

func AddRoleStringToUser

func AddRoleStringToUser(user *models.User, role string) error

func AddRoleToUser

func AddRoleToUser(user *models.User, role *models.Role) error

func Atoi

func Atoi(a string) int

func Atou

func Atou(a string) uint

func Connect

func Connect(options DBOptions) error

func ConnectRedis

func ConnectRedis(options RedisOptions)

func FindAPIKey

func FindAPIKey(key string) (*models.APIKeys, error)

func FindAirportATCByID

func FindAirportATCByID(id string) (*models.AirportATC, error)

func FindAirportByID

func FindAirportByID(id string) (*models.Airport, error)

func FindAirportChartsByID

func FindAirportChartsByID(id string) ([]*models.AirportChart, error)

func FindAirportsByARTCC

func FindAirportsByARTCC(artcc string, atc bool) ([]*models.Airport, error)

func FindOI

func FindOI(user *models.User) (string, error)

func FindRating

func FindRating(id int) (*models.Rating, error)

func FindRatingByShort

func FindRatingByShort(short string) (*models.Rating, error)

func FindRole

func FindRole(name string) (*models.Role, error)

func FindTrainingSessionRequestByID

func FindTrainingSessionRequestByID(id string) (*models.TrainingRequest, error)

func FindTrainingSessionRequestWithFilter

func FindTrainingSessionRequestWithFilter(f *TrainingSessionRequestFilter) ([]*models.TrainingRequest, error)

func FindTrainingSessionRequests

func FindTrainingSessionRequests() ([]*models.TrainingRequest, error)

func FindUserByCID

func FindUserByCID(cid string) (*models.User, error)

func FindUserByOperatingInitials

func FindUserByOperatingInitials(oi string) (*models.User, error)

func FindUserCertifications

func FindUserCertifications(user *models.User) ([]*models.UserCertification, error)

func FindUsersWithRole

func FindUsersWithRole(role string) ([]models.User, error)

func FindVisitorApplicationByCID

func FindVisitorApplicationByCID(cid string) (*models.VisitorApplication, error)

func GenerateDSN

func GenerateDSN(options DBOptions) (string, error)

func GetCabStatsForUser

func GetCabStatsForUser(user *models.User, startDate, endDate time.Time) (float32, error)

func GetCertifications

func GetCertifications() []models.Certification

func GetEnrouteStatsForUser

func GetEnrouteStatsForUser(user *models.User, startDate, endDate time.Time) (float32, error)

func GetEvent

func GetEvent(id string) (*models.Event, error)

func GetEvents

func GetEvents(limit int) ([]*models.Event, error)

func GetStatsForUserAndMonth

func GetStatsForUserAndMonth(user *models.User, month int, year int) (float32, float32, float32, error)

func GetTerminalStatsForUser

func GetTerminalStatsForUser(user *models.User, startDate, endDate time.Time) (float32, error)

func HandleCACert

func HandleCACert(driver string, cacert string) error

func InvalidateCertCache

func InvalidateCertCache()

func IsOperatingInitialsAllocated

func IsOperatingInitialsAllocated(operatingInitials string) bool

func RemoveRoleFromUser

func RemoveRoleFromUser(user *models.User, role *models.Role) error

func ValidCertification

func ValidCertification(key string) bool

Types

type DBOptions

type DBOptions struct {
	Driver   string
	Host     string
	Port     string
	User     string
	Password string
	Database string
	Options  string

	MaxOpenConns int
	MaxIdleConns int

	CACert string
	Logger *logrus.Logger
}

type Logger

type Logger struct {
	SlowThreshold         time.Duration
	SourceField           string
	SkipErrRecordNotFound bool
	// contains filtered or unexported fields
}

func NewLogger

func NewLogger(l *logrus.Logger) *Logger

func (*Logger) Debug

func (l *Logger) Debug(ctx context.Context, s string, args ...interface{})

func (*Logger) Error

func (l *Logger) Error(ctx context.Context, s string, args ...interface{})

func (*Logger) Info

func (l *Logger) Info(ctx context.Context, s string, args ...interface{})

func (*Logger) LogMode

func (l *Logger) LogMode(gormlog.LogLevel) gormlog.Interface

func (*Logger) Trace

func (l *Logger) Trace(ctx context.Context, begin time.Time, fc func() (string, int64), err error)

func (*Logger) Warn

func (l *Logger) Warn(ctx context.Context, s string, args ...interface{})

type RedisOptions

type RedisOptions struct {
	// Sentinel config
	Sentinel      bool
	MasterName    string
	SentinelAddrs []string

	// Single Redis config
	Addr string

	// Common
	Password string
	DB       int
}

type TrainingSessionRequestFilter

type TrainingSessionRequestFilter struct {
	CID    string
	Status string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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