data

package
v0.0.0-...-232a396 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2018 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanupTestData

func CleanupTestData()

func GenerateDemoData

func GenerateDemoData()

GenerateDemoData populates the database with some example information.

func GenerateDemoReadings

func GenerateDemoReadings(b *Batch)

GenerateDemoReadings generates a full time series of readings for the given batch, spaced a half hour apart.

func GetTestObjects

func GetTestObjects() (*Hydrometer, *Hydrometer, *Batch, *Batch)

func InitMongo

func InitMongo(dbAddr string, database string) error

Types

type Batch

type Batch struct {
	ID              bson.ObjectId    `bson:"_id,omitempty"`
	RecipeName      string           `bson:"recipe"`
	UniqueID        string           `bson:"stringId"`
	HydrometerID    bson.ObjectId    `bson:"hydrometer"`
	GravityReadings []GravityReading `bson:"readings"`
	StartDate       time.Time        `bson:"startDate"`
	LastUpdate      time.Time        `bson:"lastUpdate"`

	Active   bool `bson:"active"`
	Archived bool `bson:"archived"`
}

func AddBatch

func AddBatch(b *Batch) (*Batch, error)

func QueryBatches

func QueryBatches(query bson.M) ([]*Batch, error)

func SingleBatch

func SingleBatch(query bson.M) (*Batch, error)

func (*Batch) AddReading

func (b *Batch) AddReading(r GravityReading) error

func (*Batch) ArchiveBatch

func (b *Batch) ArchiveBatch() error

func (*Batch) CalculateGravityDelta

func (b *Batch) CalculateGravityDelta() float64

func (*Batch) FinishBatch

func (b *Batch) FinishBatch() error

func (*Batch) HideReadingID

func (b *Batch) HideReadingID(id bson.ObjectId) error

func (*Batch) Save

func (b *Batch) Save() error

func (*Batch) SetHydrometer

func (b *Batch) SetHydrometer(h *Hydrometer) error

func (*Batch) SetHydrometerID

func (b *Batch) SetHydrometerID(hID bson.ObjectId) error

type GravityReading

type GravityReading struct {
	ID             bson.ObjectId `json:"id" bson:"_id"`
	Date           time.Time     `json:"date" bson:"date"`
	Gravity        float64       `json:"gravity" bson:"gravity"`
	Temperature    float64       `json:"temperature" bson:"temperature"`
	BatteryVoltage float64       `json:"battery" bson:"battery"`
	Hidden         bool          `json:"hidden" bson:"hidden"`
}

type Hydrometer

type Hydrometer struct {
	ID             bson.ObjectId `bson:"_id,omitempty"`
	Name           string        `bson:"name"`
	Description    string        `bson:"description"`
	CurrentBatchID bson.ObjectId `bson:"batch"`
	Archived       bool          `bson:"archived"`
}

func QueryHydrometers

func QueryHydrometers(query bson.M) ([]*Hydrometer, error)

func SingleHydrometer

func SingleHydrometer(query bson.M) (*Hydrometer, error)

func (*Hydrometer) Save

func (h *Hydrometer) Save() error

Jump to

Keyboard shortcuts

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