db

package
v0.0.0-...-2c578c9 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2016 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DBDefaultLocation = "/tmp/quinn_db.bin"
	TableNameJournal  = "journal"
)
View Source
const (
	ColumnNameID       = "id"
	ColumnNameName     = "name"
	ColumnNameDuration = "duration"
	ColumnNameReason   = "reason"
)

Column names

Variables

View Source
var (
	QueryList    = fmt.Sprintf("select * from %s order by %s", TableNameJournal, ColumnNameID)
	QueryTotal   = fmt.Sprintf("select sum(%s) from %s", ColumnNameDuration, TableNameJournal)
	QueryHitList = fmt.Sprintf("select %s, sum(%s) from %s group by name order by sum(%s) desc",
		ColumnNameName, ColumnNameDuration, TableNameJournal, ColumnNameDuration)
)

Queries

Functions

This section is empty.

Types

type DBHandler

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

DBHandler provides DB interface for journal CLI commands

func NewDBHandler

func NewDBHandler() *DBHandler

NewDBHandler will open database and create jorunal table if it does not exist

func (*DBHandler) Hitlist

func (db *DBHandler) Hitlist() []Hit

Total sums up and returns all interrupted time

func (*DBHandler) List

func (db *DBHandler) List() []Interrupt

List all Interrupts from the DB

func (*DBHandler) Log

func (db *DBHandler) Log(name string, duration int64, reason string)

Insert a new Interrupt into the DB

func (*DBHandler) Total

func (db *DBHandler) Total() int64

Total sums up and returns all interrupted time

type Hit

type Hit struct {
	Name     string
	Duration int64 `db:"sum(duration)"`
}

Hit is structure used for hitlist query

type Interrupt

type Interrupt struct {
	Id       int64
	Name     string
	Duration int64
	Reason   string
}

Interrupt will be mapped into a DB table row

Jump to

Keyboard shortcuts

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