session

package
v0.0.0-...-3371691 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

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

DB is a SQL database storage service

func NewStore

func NewStore(name string, db *gorm.DB) (*DB, error)

NewStore creates a session store

func (*DB) ClosePendingSessionsInHistory

func (s *DB) ClosePendingSessionsInHistory(chargeMeterTotal float64) error

func (*DB) New

func (s *DB) New(meter float64) *Session

New creates a charging session

func (*DB) Persist

func (s *DB) Persist(session interface{})

Persist creates or updates a transaction in the database

func (*DB) Sessions

func (s *DB) Sessions() (Sessions, error)

Return sessions TODO make this part of server/db

type Session

type Session struct {
	ID              uint           `json:"id" csv:"-" gorm:"primarykey"`
	Created         time.Time      `json:"created"`
	Finished        time.Time      `json:"finished"`
	Loadpoint       string         `json:"loadpoint"`
	Identifier      string         `json:"identifier"`
	Vehicle         string         `json:"vehicle"`
	Odometer        *float64       `json:"odometer" format:"int"`
	MeterStart      *float64       `json:"meterStart" csv:"Meter Start (kWh)" gorm:"column:meter_start_kwh"`
	MeterStop       *float64       `json:"meterStop" csv:"Meter Stop (kWh)" gorm:"column:meter_end_kwh"`
	ChargedEnergy   float64        `json:"chargedEnergy" csv:"Charged Energy (kWh)" gorm:"column:charged_kwh"`
	ChargeDuration  *time.Duration `json:"chargeDuration" csv:"Charge Duration" gorm:"column:charge_duration"`
	SolarPercentage *float64       `json:"solarPercentage" csv:"Solar (%)" gorm:"column:solar_percentage"`
	Price           *float64       `json:"price" csv:"Price" gorm:"column:price"`
	PricePerKWh     *float64       `json:"pricePerKWh" csv:"Price/kWh" gorm:"column:price_per_kwh"`
	Co2PerKWh       *float64       `json:"co2PerKWh" csv:"CO2/kWh (gCO2eq)" gorm:"column:co2_per_kwh"`
}

Session is a single charging session

type Sessions

type Sessions []Session

Sessions is a list of sessions

func (*Sessions) WriteCsv

func (t *Sessions) WriteCsv(ctx context.Context, w io.Writer) error

WriteCsv implements the api.CsvWriter interface

Jump to

Keyboard shortcuts

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