letseat

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2024 License: BSD-2-Clause Imports: 12 Imported by: 0

Documentation

Overview

Package letseat is the main thing that decides where to go for dindin

Index

Constants

View Source
const (
	// PeopleBucket is the name of the bucket that contains all the People entries
	PeopleBucket = "people"
	// EntriesBucket is the name of the bucket that contains all the Entries entries
	EntriesBucket = "entries"
	// PlacesBucket is the name of the bucket that contains all the Places entries
	PlacesBucket = "places"
)

Variables

This section is empty.

Functions

func ParseDuration

func ParseDuration(s string) (time.Duration, error)

ParseDuration is a duration parser that supports things greater than an hour

func Stars

func Stars(num float64, icon string) string

Stars returns the number of stars for a dot rating

func WithDB

func WithDB(db *bolt.DB) func(*Diary)

WithDB sets the bbolt database for a letseat client

func WithDBFilename

func WithDBFilename(fn string) func(*Diary)

WithDBFilename uses a given file for the db

func WithEntries

func WithEntries(e Entries) func(*Diary)

WithEntries sets the diary entries on a new Diary object

func WithFilter

func WithFilter(f EntryFilter) func(*Diary)

WithFilter sets the entry filter

func WithFormat

func WithFormat(f Format) func(*Place)

WithFormat sets the format of a place using functional options

func WithName

func WithName(n string) func(*Place)

WithName sets the name of a place using functional options

Types

type Diary

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

Diary is the thing holding all of your visits and info

func New

func New(opts ...func(*Diary)) *Diary

New returns a new Diary object using functional options

func (Diary) Close

func (d Diary) Close() error

Close closes the database

func (Diary) Entries

func (d Diary) Entries() Entries

Entries returns all the entries matching the filter

func (Diary) Export

func (d Diary) Export() ([]byte, error)

Export returns all entries in yaml form

func (Diary) Get

func (d Diary) Get(k string) (*Entry, error)

Get returns an entry by it's key

func (*Diary) Log

func (d *Diary) Log(es ...Entry) error

Log logs a new entry to your diary

func (Diary) MostPopularPlace

func (d Diary) MostPopularPlace() string

MostPopularPlace just returns the most popular place

func (Diary) PlaceDetails

func (d Diary) PlaceDetails() PlaceDetails

PlaceDetails is just some detail summary pieces of the places in your diary

type Entries

type Entries []Entry

Entries is multiple DiaryEntry objects

func (*Entries) PeopleEnhanced

func (e *Entries) PeopleEnhanced() []Person

PeopleEnhanced returns all the details on people

func (*Entries) UniquePlaceNames

func (e *Entries) UniquePlaceNames() []string

UniquePlaceNames are just the simple place names as strings

type Entry

type Entry struct {
	Place     string         `yaml:"place"`
	Cost      int            `yaml:"cost,omitempty"`
	Date      *time.Time     `yaml:"date"`
	IsTakeout bool           `yaml:"takeout,omitempty"`
	Ratings   map[string]int `yaml:"ratings,omitempty"`
}

Entry represents a log about your visit to a restaurant

func (Entry) Key

func (d Entry) Key() string

Key is the key path for the database for a given entry

type EntryFilter

type EntryFilter struct {
	Place       string
	OnlyTakeout bool
	OnlyDineIn  bool
	Earliest    *time.Time
	Latest      *time.Time
}

EntryFilter defiines how to filter a list of entries

type Format

type Format struct {
	DineIn    bool
	TakeOut   bool
	FoodTruck bool
	Counter   bool
}

Format represents the type of ways you can dine at at given Place

type Person

type Person struct {
	Name            string
	PlaceAvgRatings map[string]float64
}

Person represents a person who ate and rated something at a restaurant

func (*Person) FavoriteN

func (p *Person) FavoriteN(n int) []string

FavoriteN returns the persons N favorite restaurants

type Place

type Place struct {
	Name   string `yaml:"name"`
	Slug   string `yaml:"slug"`
	Tier   int    `yaml:"tier"`
	Format Format `yaml:"format"`
}

Place is a restaurant, or place you can eat

func MustNewPlace

func MustNewPlace(options ...func(*Place)) *Place

MustNewPlace returns a new place or panics on error

func NewPlace

func NewPlace(options ...func(*Place)) (*Place, error)

NewPlace uses functional options to return a new *Place and an optional error

type PlaceDetail

type PlaceDetail struct {
	Name          string
	AverageRating float64
	LastVisit     *time.Time
	Visits        int
}

PlaceDetail is the overview detail thing of a place

type PlaceDetails

type PlaceDetails []PlaceDetail

PlaceDetails represents multiple PlaceDetail items. Satisfies the Sortable interface

func (PlaceDetails) Len

func (p PlaceDetails) Len() int

Len shows the size of the PlaceDetails

func (PlaceDetails) Less

func (p PlaceDetails) Less(i, j int) bool

Less returns if items are less than other items. Satisfies the Sortable interface

func (PlaceDetails) Swap

func (p PlaceDetails) Swap(i, j int)

Swap swaps 2 items in PlaceDetails. Satisfies the Sortable interface

type Places

type Places []Place

Places represents multiple Place objects

Jump to

Keyboard shortcuts

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