goals

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2024 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Goal

type Goal struct {
	ID              int64
	UserID          string
	Name            string
	ActivityType    *string
	MediaType       *string
	YoutubeChannels []string
	Target          time.Duration
	Current         time.Duration
	Cron            string
	DueAt           time.Time
	CreatedAt       time.Time
}

func (*Goal) IsDue

func (g *Goal) IsDue() bool

func (*Goal) MatchesActivity

func (g *Goal) MatchesActivity(a *activities.Activity) bool

func (*Goal) NextDueAt

func (g *Goal) NextDueAt(location *time.Location) (t time.Time, err error)

func (*Goal) PreviousDueAt

func (g *Goal) PreviousDueAt(location *time.Location) (t time.Time, err error)

type GoalRepository

type GoalRepository struct {
	// contains filtered or unexported fields
}

func NewGoalRepository

func NewGoalRepository(pool *pgxpool.Pool) *GoalRepository

func (*GoalRepository) BeginUpdateByUserID

func (r *GoalRepository) BeginUpdateByUserID(ctx context.Context, userID string) (goals []*Goal, tx pgx.Tx, err error)

func (*GoalRepository) Create

func (r *GoalRepository) Create(ctx context.Context, g *Goal) (err error)

func (*GoalRepository) DeleteByID

func (r *GoalRepository) DeleteByID(ctx context.Context, id int64) (err error)

func (*GoalRepository) FindByID

func (r *GoalRepository) FindByID(ctx context.Context, id int64) (goal *Goal, err error)

func (*GoalRepository) FindByUserID

func (r *GoalRepository) FindByUserID(ctx context.Context, userID string) (goals []*Goal, err error)

func (*GoalRepository) FinishUpdate

func (r *GoalRepository) FinishUpdate(ctx context.Context, tx pgx.Tx) (err error)

func (*GoalRepository) UpdateTx

func (r *GoalRepository) UpdateTx(ctx context.Context, tx pgx.Tx, g *Goal) (err error)

type GoalService

type GoalService struct {
	// contains filtered or unexported fields
}

func NewGoalService

func NewGoalService(repo *GoalRepository, ts *users.UserTimeService) *GoalService

func (*GoalService) CheckCompleted

func (s *GoalService) CheckCompleted(ctx context.Context, a *activities.Activity) (completed []*Goal, err error)

func (*GoalService) Create

func (s *GoalService) Create(ctx context.Context, g *Goal) (err error)

func (*GoalService) Delete

func (s *GoalService) Delete(ctx context.Context, goalID int64) (err error)

func (*GoalService) FindByID

func (s *GoalService) FindByID(ctx context.Context, goalID int64) (goal *Goal, err error)

func (*GoalService) FindByUserID

func (s *GoalService) FindByUserID(ctx context.Context, userID string) (goals []*Goal, err error)

func (*GoalService) NextCron

func (s *GoalService) NextCron(ctx context.Context, g *Goal) (t time.Time, err error)

func (*GoalService) PreviousCron

func (s *GoalService) PreviousCron(ctx context.Context, g *Goal) (t time.Time, err error)

Jump to

Keyboard shortcuts

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