habit

package
v0.0.0-...-9808391 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package habit provides the endpoint logic of our service. It deals with entities that are defined as part of our model.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Tick

func Tick(ctx context.Context, habitDB habitFinder, tickDB tickAdder, id ID, t time.Time) error

Tick inserts a new tick for a habit.

Types

type Habit

type Habit struct {
	ID              ID
	Name            Name
	Description     string
	WeeklyFrequency WeeklyFrequency
	CreationTime    time.Time
}

Habit to track.

func Create

func Create(ctx context.Context, db habitCreator, h Habit) (Habit, error)

Create adds a habit into the DB.

func GetStatus

func GetStatus(ctx context.Context, habitDB habitFinder, tickDB tickFinder, id ID, t time.Time) (Habit, int, error)

GetStatus returns the status a habit.

func ListHabits

func ListHabits(ctx context.Context, db habitLister) ([]Habit, error)

ListHabits returns the habits that we have in the database. TODO: Do we want this to be deterministic?

type ID

type ID string

ID is the identifier of the Habit.

type InvalidInputError

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

InvalidInputError is returned when user-input data is invalid.

func (InvalidInputError) Error

func (e InvalidInputError) Error() string

Error implements error.

type Name

type Name string

Name is a short string that represents the name of a Habit.

type WeeklyFrequency

type WeeklyFrequency uint

WeeklyFrequency is the number of times a Habit should happen every week.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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