usage

package
v0.0.0-...-af27be7 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2017 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	DBLocation string
}

type DailyMonthlyLimits

type DailyMonthlyLimits struct {
	Daily   Limits `json:"daily"`
	Monthly Limits `json:"monthly"`
}

type Limits

type Limits struct {
	MinMaxTimestamp   `json:"timestamp"`
	MinMaxConsumption `json:"consumption"`
	MinMaxTemperature `json:"temperature"`
}

type MinMaxConsumption

type MinMaxConsumption struct {
	Minimum int `json:"minimum"`
	Maximum int `json:"maximum"`
}

type MinMaxTemperature

type MinMaxTemperature struct {
	Minimum int `json:"minimum"`
	Maximum int `json:"maximum"`
}

type MinMaxTimestamp

type MinMaxTimestamp struct {
	Minimum string `json:"minimum"`
	Maximum string `json:"maximum"`
}

type UsageProcessor

type UsageProcessor struct {
	Storage UsageStorage
}

func NewProcessor

func NewProcessor(config Config) (UsageProcessor, error)

func (UsageProcessor) GetDataForUser

func (processor UsageProcessor) GetDataForUser(
	userId int,
	count int,
	resolution string,
	start string) ([][]interface{}, error)

GetDataForUser fetches the temperature, consumption data for the user based on the starting date provided.

func (UsageProcessor) GetLimitsForUser

func (processor UsageProcessor) GetLimitsForUser(userId int) (DailyMonthlyLimits, error)

GetLimitsForUser fetches the daily and monthly limits for the temperature, consumption and timestamp for the provided user.

type UsageStorage

type UsageStorage struct {
	DB *sql.DB
}

func NewStorage

func NewStorage(location string) (UsageStorage, error)

func (UsageStorage) AddDailyLimit

func (storage UsageStorage) AddDailyLimit(
	userId,
	dayId,
	temperature,
	consumption int,
	timestamp string) error

func (UsageStorage) AddMonthlyLimit

func (storage UsageStorage) AddMonthlyLimit(
	userId,
	monthId,
	temperature,
	consumption int,
	timestamp string) error

func (UsageStorage) AddNewUser

func (storage UsageStorage) AddNewUser(userId int, username string, password string) error

func (UsageStorage) GetDailyLimits

func (storage UsageStorage) GetDailyLimits(userId int) (Limits, error)

func (UsageStorage) GetDailyUserData

func (storage UsageStorage) GetDailyUserData(
	userId int,
	count int,
	start string) ([][]interface{}, error)

func (UsageStorage) GetMonthlyLimits

func (storage UsageStorage) GetMonthlyLimits(userId int) (Limits, error)

func (UsageStorage) GetMonthlyUserData

func (storage UsageStorage) GetMonthlyUserData(
	userId int,
	count int,
	start string) ([][]interface{}, error)

func (UsageStorage) GetUser

func (storage UsageStorage) GetUser(username string, password string) (User, error)

type User

type User struct {
	UserId   int    `db:"user_id"`
	UserName string `db:"username"`
	Password string `db:"password"`
}

type UserData

type UserData struct {
	Timestamp   string `json:"timestamp"`
	Temperature int    `json:"temperature"`
	Consumption int    `json:"consumption"`
}

Jump to

Keyboard shortcuts

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