internal

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateSensorParams

type CreateSensorParams struct {
	Code         string    `json:"code"`
	Label        string    `json:"label"`
	Kind         string    `json:"kind"`
	Unit         string    `json:"unit"`
	Location     *string   `json:"location"`
	Active       int64     `json:"active"`
	Firmware     string    `json:"firmware"`
	SampleRateMs int64     `json:"sample_rate_ms"`
	InstalledAt  time.Time `json:"installed_at"`
	CreatedAt    time.Time `json:"created_at"`
	UpdatedAt    time.Time `json:"updated_at"`
}

type CreateSensorReadingParams added in v0.0.6

type CreateSensorReadingParams struct {
	SensorID   int64     `json:"sensor_id"`
	Value      float64   `json:"value"`
	Quality    int64     `json:"quality"`
	Flagged    int64     `json:"flagged"`
	RecordedAt time.Time `json:"recorded_at"`
	CreatedAt  time.Time `json:"created_at"`
}

type DBTX

type DBTX interface {
	ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
	PrepareContext(context.Context, string) (*sql.Stmt, error)
	QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
	QueryRowContext(context.Context, string, ...interface{}) *sql.Row
}

type GetSensorReadingStatsParams

type GetSensorReadingStatsParams struct {
	SensorID int64     `json:"sensor_id"`
	FromTs   time.Time `json:"from_ts"`
	ToTs     time.Time `json:"to_ts"`
}

type GetSensorReadingStatsRow

type GetSensorReadingStatsRow struct {
	ReadingCount int64       `json:"reading_count"`
	AvgValue     *float64    `json:"avg_value"`
	MinValue     interface{} `json:"min_value"`
	MaxValue     interface{} `json:"max_value"`
}

type ListSensorFilterByLabelKindActiveParams

type ListSensorFilterByLabelKindActiveParams struct {
	Label  string `json:"label"`
	Kind   string `json:"kind"`
	Active int64  `json:"active"`
	Offset int64  `json:"offset"`
	Limit  int64  `json:"limit"`
}

type ListSensorFilterByLabelKindActiveRow added in v0.0.5

type ListSensorFilterByLabelKindActiveRow struct {
	ID           int64     `json:"id"`
	Code         string    `json:"code"`
	Label        string    `json:"label"`
	Kind         string    `json:"kind"`
	Unit         string    `json:"unit"`
	Location     *string   `json:"location"`
	Active       int64     `json:"active"`
	Firmware     string    `json:"firmware"`
	SampleRateMs int64     `json:"sample_rate_ms"`
	InstalledAt  time.Time `json:"installed_at"`
	CreatedAt    time.Time `json:"created_at"`
	UpdatedAt    time.Time `json:"updated_at"`
	TotalSize    int64     `json:"total_size"`
}

type ListSensorReadingBySensorIdParams added in v0.0.6

type ListSensorReadingBySensorIdParams struct {
	SensorID int64 `json:"sensor_id"`
	Offset   int64 `json:"offset"`
	Limit    int64 `json:"limit"`
}

type ListSensorReadingFilterBySensorIdRecordedAtFlaggedParams added in v0.0.6

type ListSensorReadingFilterBySensorIdRecordedAtFlaggedParams struct {
	SensorID      int64     `json:"sensor_id"`
	MinRecordedAt time.Time `json:"min_recorded_at"`
	MaxRecordedAt time.Time `json:"max_recorded_at"`
	Flagged       int64     `json:"flagged"`
	Offset        int64     `json:"offset"`
	Limit         int64     `json:"limit"`
}

type ListSensorReadingFilterBySensorIdRecordedAtFlaggedRow added in v0.0.6

type ListSensorReadingFilterBySensorIdRecordedAtFlaggedRow struct {
	ID         int64     `json:"id"`
	SensorID   int64     `json:"sensor_id"`
	Value      float64   `json:"value"`
	Quality    int64     `json:"quality"`
	Flagged    int64     `json:"flagged"`
	RecordedAt time.Time `json:"recorded_at"`
	CreatedAt  time.Time `json:"created_at"`
	TotalSize  int64     `json:"total_size"`
}

type ListSensorsWithLatestReadingParams

type ListSensorsWithLatestReadingParams struct {
	Offset int64 `json:"offset"`
	Limit  int64 `json:"limit"`
}

type ListSensorsWithLatestReadingRow

type ListSensorsWithLatestReadingRow struct {
	Sensor           Sensor     `json:"sensor"`
	LatestValue      *float64   `json:"latest_value"`
	LatestRecordedAt *time.Time `json:"latest_recorded_at"`
}

type Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) CreateSensor

func (q *Queries) CreateSensor(ctx context.Context, arg CreateSensorParams) (int64, error)

Code generated by entlite. DO NOT EDIT. SQLC compatible query definitions Sensor CRUD operations

func (*Queries) CreateSensorReading added in v0.0.6

func (q *Queries) CreateSensorReading(ctx context.Context, arg CreateSensorReadingParams) (int64, error)

SensorReading CRUD operations

func (*Queries) DB

func (q *Queries) DB() DBTX

DB returns the handle this Queries was constructed with.

func (*Queries) DeleteSensor

func (q *Queries) DeleteSensor(ctx context.Context, id int64) error

func (*Queries) DeleteSensorReading added in v0.0.6

func (q *Queries) DeleteSensorReading(ctx context.Context, id int64) error

func (*Queries) GetSensorByCode

func (q *Queries) GetSensorByCode(ctx context.Context, code string) (Sensor, error)

Look up a sensor by its hardware code

func (*Queries) GetSensorById added in v0.0.6

func (q *Queries) GetSensorById(ctx context.Context, id int64) (Sensor, error)

func (*Queries) GetSensorReadingById added in v0.0.6

func (q *Queries) GetSensorReadingById(ctx context.Context, id int64) (SensorReading, error)

func (*Queries) GetSensorReadingStats

func (q *Queries) GetSensorReadingStats(ctx context.Context, arg GetSensorReadingStatsParams) (GetSensorReadingStatsRow, error)

Hand-written queries the DSL cannot express. entlite never writes this file. The tables are defined in the generated schema.sql. Aggregate value statistics for a single sensor over a time window. >= / <= instead of BETWEEN: sqlc drops the bounds from the params struct unless the range is the first filter.

func (*Queries) ListSensorReadingBySensorId added in v0.0.6

func (q *Queries) ListSensorReadingBySensorId(ctx context.Context, arg ListSensorReadingBySensorIdParams) ([]SensorReading, error)

func (*Queries) ListSensorsWithLatestReading

func (q *Queries) ListSensorsWithLatestReading(ctx context.Context, arg ListSensorsWithLatestReadingParams) ([]ListSensorsWithLatestReadingRow, error)

Every active sensor with its most recent reading. LEFT JOIN, so a sensor that never reported comes back with NULL latest values. sqlc.embed(s) maps the joined columns back to the Sensor struct.

func (*Queries) PruneReadingsOlderThan

func (q *Queries) PruneReadingsOlderThan(ctx context.Context, cutoff time.Time) (int64, error)

Drops readings older than a cutoff.

func (*Queries) UpdateSensor

func (q *Queries) UpdateSensor(ctx context.Context, arg UpdateSensorParams) (Sensor, error)

func (*Queries) UpdateSensorReading added in v0.0.6

func (q *Queries) UpdateSensorReading(ctx context.Context, arg UpdateSensorReadingParams) (SensorReading, error)

func (*Queries) WithTx

func (q *Queries) WithTx(tx *sql.Tx) *Queries

type Sensor

type Sensor struct {
	ID           int64     `json:"id"`
	Code         string    `json:"code"`
	Label        string    `json:"label"`
	Kind         string    `json:"kind"`
	Unit         string    `json:"unit"`
	Location     *string   `json:"location"`
	Active       int64     `json:"active"`
	Firmware     string    `json:"firmware"`
	SampleRateMs int64     `json:"sample_rate_ms"`
	InstalledAt  time.Time `json:"installed_at"`
	CreatedAt    time.Time `json:"created_at"`
	UpdatedAt    time.Time `json:"updated_at"`
}

type SensorReading added in v0.0.6

type SensorReading struct {
	ID         int64     `json:"id"`
	SensorID   int64     `json:"sensor_id"`
	Value      float64   `json:"value"`
	Quality    int64     `json:"quality"`
	Flagged    int64     `json:"flagged"`
	RecordedAt time.Time `json:"recorded_at"`
	CreatedAt  time.Time `json:"created_at"`
}

type UpdateSensorParams

type UpdateSensorParams struct {
	Code         string    `json:"code"`
	Label        string    `json:"label"`
	Kind         string    `json:"kind"`
	Unit         string    `json:"unit"`
	Location     *string   `json:"location"`
	Active       *int64    `json:"active"`
	Firmware     *string   `json:"firmware"`
	SampleRateMs *int64    `json:"sample_rate_ms"`
	UpdatedAt    time.Time `json:"updated_at"`
	ID           int64     `json:"id"`
}

type UpdateSensorReadingParams added in v0.0.6

type UpdateSensorReadingParams struct {
	SensorID   int64     `json:"sensor_id"`
	Value      float64   `json:"value"`
	Quality    int64     `json:"quality"`
	Flagged    *int64    `json:"flagged"`
	RecordedAt time.Time `json:"recorded_at"`
	ID         int64     `json:"id"`
}

Jump to

Keyboard shortcuts

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