model

package
v0.0.0-...-a8eaf85 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2015 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteLeaveAllowance

func DeleteLeaveAllowance(id, jobID uint64) (err error)

func DeleteLeaveRequest

func DeleteLeaveRequest(id, jobID uint64) (err error)

func InitDB

func InitDB(driver, database string)

func SetLogger

func SetLogger(l *logrus.Logger)

Types

type Job

type Job struct {
	ID              uint64 `gorm:"column:id; primary_key:yes"`
	ExportSecret    string
	User            User
	UserID          uint64    `gorm:"column:user_id"`
	StartTime       time.Time `sql:"DEFAULT:null"`
	EndTime         time.Time `sql:"DEFAULT:null"`
	EmployerName    string
	LeaveAllowances []LeaveAllowance
	LeaveRequests   []LeaveRequest

	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt time.Time
}

func FindJobFromExportSecret

func FindJobFromExportSecret(secret string) (j Job, err error)

func (*Job) CurrentLeaveAllowance

func (j *Job) CurrentLeaveAllowance() (l LeaveAllowance, _ error)

func (*Job) LeavePeriods

func (j *Job) LeavePeriods() (l []LeaveAllowance, _ error)

func (*Job) RequestsLastYearAndFuture

func (j *Job) RequestsLastYearAndFuture() (requests []LeaveRequest, err error)

func (*Job) Save

func (j *Job) Save() error

type LeaveAllowance

type LeaveAllowance struct {
	ID           uint64 `gorm:"column:id; primary_key:yes"`
	Job          Job
	JobID        uint64    `gorm:"column:job_id"`
	StartTime    time.Time `sql:"DEFAULT:null"`
	EndTime      time.Time `sql:"DEFAULT:null"`
	Minutes      int32
	Description  string
	IsAdjustment bool

	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt time.Time
}

func FindLeaveAllowance

func FindLeaveAllowance(id, jobID uint64) (l LeaveAllowance, err error)

func (*LeaveAllowance) IntersectsLeaveRequest

func (a *LeaveAllowance) IntersectsLeaveRequest() (intersects LeaveRequest, _ error)

IntersectsLeaveRequests checks if a leave allowance starts or ends part-way through any existing leave requests for the same job.

This query can be used to ensure that changes to a leave allowance will not cause leave requests to span leave allowance periods, which is currently not supported.

func (*LeaveAllowance) OverlapsAnother

func (a *LeaveAllowance) OverlapsAnother() (overlaps LeaveAllowance, _ error)

func (*LeaveAllowance) RemainingTime

func (l *LeaveAllowance) RemainingTime() (minutes int32, err error)

func (*LeaveAllowance) Save

func (a *LeaveAllowance) Save() error

type LeaveRequest

type LeaveRequest struct {
	ID          uint64 `gorm:"column:id; primary_key:yes"`
	Job         Job
	JobID       uint64 `gorm:"column:job_id"`
	Minutes     uint32
	Description string
	StartTime   time.Time `sql:"DEFAULT:null"`
	EndTime     time.Time `sql:"DEFAULT:null"`

	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt time.Time
}

func FindLeaveRequest

func FindLeaveRequest(id, jobID uint64) (l LeaveRequest, err error)

func (*LeaveRequest) After

func (r *LeaveRequest) After(t time.Time) bool

func (*LeaveRequest) Before

func (r *LeaveRequest) Before(t time.Time) bool

func (*LeaveRequest) FitsExistingAllowancePeriod

func (r *LeaveRequest) FitsExistingAllowancePeriod() (result int, err error)

func (*LeaveRequest) Save

func (r *LeaveRequest) Save() error

type User

type User struct {
	ID       uint64 `gorm:"column:id; primary_key:yes"`
	Name     string `sql:"type:text;"`
	GitHubID uint64 `gorm:"column:github_id"`
	Email    string `sql:"type:text;"`
	TZOffset int16  `gorm:"column:tz_offset"` // time zone as seconds east of UTC
	Jobs     []Job

	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt time.Time
}

func FindUser

func FindUser(id uint64) (user User, err error)

func (*User) CurrentJob

func (u *User) CurrentJob() Job

func (*User) Save

func (u *User) Save() error

func (*User) TZLocation

func (u *User) TZLocation() *time.Location

func (*User) UpdateOrCreate

func (u *User) UpdateOrCreate() error

Jump to

Keyboard shortcuts

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