models

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidHabitTitle = app.Errorf(app.EINVALID, "Invalid habit title.")

Functions

This section is empty.

Types

type Chain

type Chain struct {
	Title  string
	Habits []*Habit
}

type Habit

type Habit struct {
	Id          HabitId    `json:"id"`
	Title       HabitTitle `json:"title"`
	Day         time.Time  `json:"day"`
	IsCompleted bool       `json:"is_completed"`
	UpdatedAt   time.Time  `json:"updated_at"`
}

func CreateHabit

func CreateHabit(title HabitTitle, day time.Time, isCompleted bool) (*Habit, error)

func (*Habit) ChangeTitle

func (h *Habit) ChangeTitle(title string) error

func (*Habit) ToggleCompletion

func (h *Habit) ToggleCompletion()

type HabitId

type HabitId int

type HabitService

type HabitService interface {
	// All the habits for heat map
	HeatMap(ctx context.Context, from time.Time, to time.Time) (map[time.Time]*HeatMap, int, error)
	// Get all the habits for the given day
	GetAllByDay(ctx context.Context, day time.Time) (*Chain, error)
	Create(ctx context.Context, habit *Habit) error
	// delete a habit
	Delete(ctx context.Context, id HabitId) error
	Update(ctx context.Context, habit *Habit) error
}

type HabitTitle

type HabitTitle string

func CreateHabitTitle

func CreateHabitTitle(title string) (HabitTitle, error)

func (HabitTitle) String

func (ht HabitTitle) String() string

type HeatMap

type HeatMap struct {
	TotalNumberOfHabits int
	CompletedHabits     int
	Day                 int
	Month               int
	Year                int
}

Jump to

Keyboard shortcuts

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