internal

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 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 CreateReadingParams

type CreateReadingParams 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 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 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 ListReadingFilterBySensorIdRecordedAtFlaggedParams

type ListReadingFilterBySensorIdRecordedAtFlaggedParams struct {
	SensorID int64 `json:"sensor_id"`
	Flagged  int64 `json:"flagged"`
}

type ListSensorFilterByLabelKindActiveParams

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

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) CreateReading

func (q *Queries) CreateReading(ctx context.Context, arg CreateReadingParams) (int64, error)

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

func (*Queries) CreateSensor

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

Sensor CRUD operations

func (*Queries) DB

func (q *Queries) DB() DBTX

DB returns the handle this Queries was constructed with.

func (*Queries) DeleteReading

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

func (*Queries) DeleteSensor

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

func (*Queries) GetReadingByID

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

func (*Queries) GetSensorByCode

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

func (*Queries) GetSensorByID

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

func (*Queries) GetSensorReadingStats

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

custom.sql

Hand-written queries that live ALONGSIDE the DSL-generated queries.sql. entlite never touches this file, so anything here survives regeneration. These are queries the DSL query builder cannot express: cross-table JOINs, aggregates, and bulk maintenance operations.

The tables ("sensor", "reading") are defined in the generated schema.sql. Aggregate value statistics for a single sensor over a time window. Note: written as >= / <= rather than BETWEEN, because sqlc cannot infer the type of a DATETIME placeholder inside BETWEEN and silently drops it from the generated params struct.

func (*Queries) ListReadingBySensorId

func (q *Queries) ListReadingBySensorId(ctx context.Context, sensorID int64) ([]Reading, error)

func (*Queries) ListReadingFilterBySensorIdRecordedAtFlagged

func (q *Queries) ListReadingFilterBySensorIdRecordedAtFlagged(ctx context.Context, arg ListReadingFilterBySensorIdRecordedAtFlaggedParams) ([]Reading, error)

func (*Queries) ListSensorFilterByLabelKindActive

func (q *Queries) ListSensorFilterByLabelKindActive(ctx context.Context, arg ListSensorFilterByLabelKindActiveParams) ([]Sensor, error)

func (*Queries) ListSensorsWithLatestReading

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

Every active sensor together with its most recent reading (LEFT JOIN, so sensors that have never reported still show up with NULL latest values). sqlc.embed(s) maps the joined sensor columns back to the full Sensor struct.

func (*Queries) PruneReadingsOlderThan

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

Retention: drop readings older than a cutoff. Returns nothing.

func (*Queries) UpdateReading

func (q *Queries) UpdateReading(ctx context.Context, arg UpdateReadingParams) (Reading, error)

func (*Queries) UpdateSensor

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

func (*Queries) WithTx

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

type Reading

type Reading 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 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 UpdateReadingParams

type UpdateReadingParams 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"`
}

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"`
}

Jump to

Keyboard shortcuts

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