repositories

package
v0.0.0-...-b9360c4 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2023 License: BSD-3-Clause Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ManufacturerConservify = 0x01
	ConservifyWeather      = 0x01
	ConservifyAtlas        = 0x02
	ConservifyDistance     = 0x03
	ConservifyAtlasPh      = 0x04
	ConservifyAtlasEc      = 0x05
	ConservifyAtlasDo      = 0x06
	ConservifyAtlasTemp    = 0x07
	ConservifyAtlasOrp     = 0x08
	ConservifyWaterPh      = 0x09
	ConservifyWaterEc      = 0x10
	ConservifyWaterDo      = 0x11
	ConservifyWaterTemp    = 0x12
	ConservifyWaterOrp     = 0x13
	ConservifyRandom       = 0xa0
	ConservifyDiagnostics  = 0xa1
)
View Source
const (
	META_INTERNAL_MASK = 0x1
)
View Source
const (
	MaximumRequiredHeaderBytes = 262
)

Variables

View Source
var (
	StatusReplySourceID = int32(0)
)

Functions

func Logger

func Logger(ctx context.Context) *zap.Logger

Types

type ActivityRepository

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

func NewActivityRepository

func NewActivityRepository(db *sqlxcache.DB) (r *ActivityRepository, err error)

func (*ActivityRepository) QueryProjectActivityStations

func (r *ActivityRepository) QueryProjectActivityStations(ctx context.Context, projectID int64, pageSize, offset int32) ([]*data.Station, error)

func (*ActivityRepository) QueryProjectUpdate

func (r *ActivityRepository) QueryProjectUpdate(ctx context.Context, projectID int64, pageSize, offset int32) ([]*data.ProjectUpdateWM, error)

func (*ActivityRepository) QueryStationDeployed

func (r *ActivityRepository) QueryStationDeployed(ctx context.Context, projectID, stationID *int64, pageSize, offset int32) ([]*data.StationDeployedWM, error)

func (*ActivityRepository) QueryStationIngested

func (r *ActivityRepository) QueryStationIngested(ctx context.Context, projectID, stationID *int64, pageSize, offset int32) ([]*data.StationIngestionWM, error)

type AllModuleMeta

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

func (*AllModuleMeta) All

func (moduleMeta *AllModuleMeta) All() []*ModuleMeta

func (*AllModuleMeta) FindModuleMeta

func (moduleMeta *AllModuleMeta) FindModuleMeta(m *HeaderFields) (mm *ModuleMeta, err error)

func (*AllModuleMeta) FindSensorByFullKey

func (moduleMeta *AllModuleMeta) FindSensorByFullKey(fullKey string) *SensorAndModuleMeta

func (*AllModuleMeta) FindSensorMeta

func (moduleMeta *AllModuleMeta) FindSensorMeta(m *HeaderFields, sensor string) (mm *ModuleMeta, sm *SensorMeta, err error)

type AssociatedStation

type AssociatedStation struct {
	StationID           int32 `db:"station_id"`
	AssociatedStationID int32 `db:"associated_station_id"`
	Priority            int32 `db:"priority"`
}

type AttributesRepository

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

func NewAttributesRepository

func NewAttributesRepository(db *sqlxcache.DB) (rr *AttributesRepository)

func (*AttributesRepository) QueryStationProjectAttributes

func (r *AttributesRepository) QueryStationProjectAttributes(ctx context.Context, stationID int32) ([]*data.StationAttributeSlot, error)

func (*AttributesRepository) UpsertStationAttributes

func (r *AttributesRepository) UpsertStationAttributes(ctx context.Context, attributes []*data.StationProjectAttribute) ([]*data.StationProjectAttribute, error)

type BookmarkRepository

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

func NewBookmarkRepository

func NewBookmarkRepository(db *sqlxcache.DB) (rr *BookmarkRepository)

func (*BookmarkRepository) AddNew

func (c *BookmarkRepository) AddNew(ctx context.Context, userID *int32, bookmark string) (*SavedBookmark, error)

func (*BookmarkRepository) Resolve

func (c *BookmarkRepository) Resolve(ctx context.Context, token string) (*SavedBookmark, error)

type CountingReader

type CountingReader struct {
	BytesRead int64
	// contains filtered or unexported fields
}

func NewCountingReader

func NewCountingReader(target io.Reader) *CountingReader

func (*CountingReader) Read

func (r *CountingReader) Read(p []byte) (n int, err error)

type DataMetaModule

type DataMetaModule struct {
	Position     int               `json:"position"`
	Address      int               `json:"address"`
	Manufacturer int               `json:"manufacturer"`
	Kind         int               `json:"kind"`
	Version      int               `json:"version"`
	Name         string            `json:"name"`
	ID           string            `json:"id"`
	Key          string            `json:"key"`
	Sensors      []*DataMetaSensor `json:"sensors"`
	Internal     bool              `json:"internal"`
}

type DataMetaSensor

type DataMetaSensor struct {
	Number        int            `json:"number"`
	Name          string         `json:"name"`
	Key           string         `json:"key"`
	FirmwareKey   string         `json:"firmware_key"`
	FullKey       string         `json:"full_key"`
	UnitOfMeasure string         `json:"unit_of_measure"`
	Internal      bool           `json:"internal"`
	Ranges        []SensorRanges `json:"ranges"`
}

type DataMetaStation

type DataMetaStation struct {
	ID         string                   `json:"id"`
	Name       string                   `json:"name"`
	Firmware   *DataMetaStationFirmware `json:"firmware"`
	AllModules []*DataMetaModule        `json:"all_modules"`
}

type DataMetaStationFirmware

type DataMetaStationFirmware struct {
	Version   string `json:"version"`
	Build     string `json:"build"`
	Number    string `json:"number"`
	Timestamp uint64 `json:"timestamp"`
	Hash      string `json:"hash"`
}

type DataSummary

type DataSummary struct {
	Start               *time.Time `db:"start"`
	End                 *time.Time `db:"end"`
	NumberOfDataRecords int64      `db:"number_of_data_records"`
	NumberOfMetaRecords int64      `db:"number_of_meta_records"`
}

type DescribesExport

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

func NewDescribeEvent

func NewDescribeEvent(db *sqlxcache.DB) *DescribesExport

func (*DescribesExport) Describe

func (d *DescribesExport) Describe(ctx context.Context, created time.Time, stationIds []int32) (string, error)

type DiscussionRepository

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

func NewDiscussionRepository

func NewDiscussionRepository(db *sqlxcache.DB) (rr *DiscussionRepository)

func (*DiscussionRepository) AddPost

func (*DiscussionRepository) DeletePostByID

func (r *DiscussionRepository) DeletePostByID(ctx context.Context, id int64) error

func (*DiscussionRepository) QueryByProjectID

func (r *DiscussionRepository) QueryByProjectID(ctx context.Context, id int32) (*data.PageOfDiscussion, error)

func (*DiscussionRepository) QueryByStationIDs

func (r *DiscussionRepository) QueryByStationIDs(ctx context.Context, ids []int32) (*data.PageOfDiscussion, error)

func (*DiscussionRepository) QueryPostByID

func (r *DiscussionRepository) QueryPostByID(ctx context.Context, id int64) (*data.DiscussionPost, error)

func (*DiscussionRepository) UpdatePostByID

func (r *DiscussionRepository) UpdatePostByID(ctx context.Context, post *data.DiscussionPost) (*data.DiscussionPost, error)

type EssentialQueryParams

type EssentialQueryParams struct {
	Page     int32
	PageSize int32
}

type EventRepository

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

func NewEventRepository

func NewEventRepository(db *sqlxcache.DB) (rr *EventRepository)

func (*EventRepository) AddDataEvent

func (r *EventRepository) AddDataEvent(ctx context.Context, event *data.DataEvent) (*data.DataEvent, error)

func (*EventRepository) DeleteEventByID

func (r *EventRepository) DeleteEventByID(ctx context.Context, id int64) error

func (*EventRepository) QueryByProjectIDs

func (r *EventRepository) QueryByProjectIDs(ctx context.Context, ids []int32) (*data.DataEvents, error)

func (*EventRepository) QueryByStationIDs

func (r *EventRepository) QueryByStationIDs(ctx context.Context, ids []int32) (*data.DataEvents, error)

func (*EventRepository) QueryEventByID

func (r *EventRepository) QueryEventByID(ctx context.Context, id int64) (*data.DataEvent, error)

func (*EventRepository) UpdateEventByID

func (r *EventRepository) UpdateEventByID(ctx context.Context, event *data.DataEvent) (*data.DataEvent, error)

type ExportRepository

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

func NewExportRepository

func NewExportRepository(db *sqlxcache.DB) (*ExportRepository, error)

func (*ExportRepository) AddDataExport

func (r *ExportRepository) AddDataExport(ctx context.Context, de *data.DataExport) (i *data.DataExport, err error)

func (*ExportRepository) AddDataExportWithArgs

func (r *ExportRepository) AddDataExportWithArgs(ctx context.Context, de *data.DataExport, args interface{}) (i *data.DataExport, err error)

func (*ExportRepository) QueryByID

func (r *ExportRepository) QueryByID(ctx context.Context, id int64) (i *data.DataExport, err error)

func (*ExportRepository) QueryByToken

func (r *ExportRepository) QueryByToken(ctx context.Context, token string) (i *data.DataExport, err error)

func (*ExportRepository) QueryByUserID

func (r *ExportRepository) QueryByUserID(ctx context.Context, userID int32) (i []*data.DataExport, err error)

func (*ExportRepository) UpdateDataExport

func (r *ExportRepository) UpdateDataExport(ctx context.Context, de *data.DataExport) (i *data.DataExport, err error)

type Filter

type Filter interface {
	Name() string
	Apply(ctx context.Context, record *ResolvedRecord, filters *MatchedFilters)
}

type FilteredRecord

type FilteredRecord struct {
	Record  *ResolvedRecord `json:"record"`
	Filters *MatchedFilters `json:"filters"`
}

type Filtering

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

func NewFiltering

func NewFiltering() (f *Filtering)

func (*Filtering) Apply

func (f *Filtering) Apply(ctx context.Context, record *ResolvedRecord) *FilteredRecord

type HeaderFields

type HeaderFields struct {
	Manufacturer uint32
	Kind         uint32
}

type IngestionRepository

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

func NewIngestionRepository

func NewIngestionRepository(db *sqlxcache.DB) (ir *IngestionRepository)

func (*IngestionRepository) AddAndQueue

func (r *IngestionRepository) AddAndQueue(ctx context.Context, ingestion *data.Ingestion) (queueID int64, err error)

func (*IngestionRepository) Delete

func (r *IngestionRepository) Delete(ctx context.Context, ingestionID int64) (err error)

func (*IngestionRepository) Enqueue

func (r *IngestionRepository) Enqueue(ctx context.Context, ingestionID int64) (int64, error)

func (*IngestionRepository) MarkProcessedDone

func (r *IngestionRepository) MarkProcessedDone(ctx context.Context, queuedID, totalRecords, metaErrors, dataErrors int64) error

func (*IngestionRepository) MarkProcessedHasOtherErrors

func (r *IngestionRepository) MarkProcessedHasOtherErrors(ctx context.Context, queuedID int64) error

func (*IngestionRepository) QueryByID

func (r *IngestionRepository) QueryByID(ctx context.Context, id int64) (i *data.Ingestion, err error)

func (*IngestionRepository) QueryByStationID

func (r *IngestionRepository) QueryByStationID(ctx context.Context, id int32) (all []*data.Ingestion, err error)

func (*IngestionRepository) QueryPending

func (r *IngestionRepository) QueryPending(ctx context.Context) (all []*data.QueuedIngestion, err error)

func (*IngestionRepository) QueryQueuedByID

func (r *IngestionRepository) QueryQueuedByID(ctx context.Context, queuedID int64) (i *data.QueuedIngestion, err error)

type InterestingnessRepository

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

func NewInterestingnessRepository

func NewInterestingnessRepository(db *sqlxcache.DB) (rr *InterestingnessRepository)

func (*InterestingnessRepository) QueryByStationID

func (*InterestingnessRepository) UpsertInterestingness

type LoadedMedia

type LoadedMedia struct {
	Key      string
	Size     int64
	MimeType string
	Reader   io.Reader
}

type MalformedMetaError

type MalformedMetaError struct {
	MetaRecordID int64
	Malformed    string
}

func (*MalformedMetaError) Error

func (e *MalformedMetaError) Error() string

type MatchedFilters

type MatchedFilters struct {
	Record   []string               `json:"record"`
	Readings map[SensorKey][]string `json:"-"`
}

func (*MatchedFilters) AddReading

func (mf *MatchedFilters) AddReading(key SensorKey, name string)

func (*MatchedFilters) AddRecord

func (mf *MatchedFilters) AddRecord(name string)

func (*MatchedFilters) IsFiltered

func (mf *MatchedFilters) IsFiltered(sensorKey SensorKey) bool

func (*MatchedFilters) NumberOfReadingsFiltered

func (mf *MatchedFilters) NumberOfReadingsFiltered() int

type MediaRepository

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

func NewMediaRepository

func NewMediaRepository(files files.FileArchive) (r *MediaRepository)

func (*MediaRepository) DeleteByURL

func (r *MediaRepository) DeleteByURL(ctx context.Context, url string) (err error)

func (*MediaRepository) LoadByURL

func (r *MediaRepository) LoadByURL(ctx context.Context, url string) (lm *LoadedMedia, err error)

func (*MediaRepository) Save

func (r *MediaRepository) Save(ctx context.Context, reader io.ReadCloser, contentLength int64, givenContentType string) (sm *SavedMedia, err error)

type MetaFactory

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

func NewMetaFactory

func NewMetaFactory(db *sqlxcache.DB) *MetaFactory

func (*MetaFactory) Add

func (mf *MetaFactory) Add(ctx context.Context, databaseRecord *data.MetaRecord, fq bool) (*VersionMeta, error)

func (*MetaFactory) InOrder

func (mf *MetaFactory) InOrder() []*VersionMeta

func (*MetaFactory) Resolve

func (mf *MetaFactory) Resolve(ctx context.Context, databaseRecord *data.DataRecord, verbose bool, fq bool) (*FilteredRecord, error)

type MissingSensorMetaError

type MissingSensorMetaError struct {
	MetaRecordID int64
}

func (*MissingSensorMetaError) Error

func (e *MissingSensorMetaError) Error() string

type ModuleHeader

type ModuleHeader struct {
	Manufacturer uint32   `json:"manufacturer"`
	Kind         uint32   `json:"kind"`
	Version      uint32   `json:"version"`
	AllKinds     []uint32 `json:"all_kinds"`
}

type ModuleMeta

type ModuleMeta struct {
	Header   ModuleHeader  `json:"header"`
	Key      string        `json:"key"`
	Internal bool          `json:"internal"`
	Sensors  []*SensorMeta `json:"sensors"`
}

func (*ModuleMeta) Sensor

func (mm *ModuleMeta) Sensor(key string) *SensorMeta

type ModuleMetaRepository

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

func NewModuleMetaRepository

func NewModuleMetaRepository(db *sqlxcache.DB) *ModuleMetaRepository

func (*ModuleMetaRepository) FindAllModulesMeta

func (r *ModuleMetaRepository) FindAllModulesMeta(ctx context.Context) (mm *AllModuleMeta, err error)

func (*ModuleMetaRepository) FindByFullKey

func (r *ModuleMetaRepository) FindByFullKey(ctx context.Context, fullKey string) (mm *SensorAndModuleMeta, err error)

func (*ModuleMetaRepository) FindModuleMeta

func (r *ModuleMetaRepository) FindModuleMeta(ctx context.Context, m *HeaderFields) (mm *ModuleMeta, err error)

func (*ModuleMetaRepository) FindSensorMeta

func (r *ModuleMetaRepository) FindSensorMeta(ctx context.Context, m *HeaderFields, sensor string) (mm *ModuleMeta, sm *SensorMeta, err error)

type NearbyStation

type NearbyStation struct {
	StationID int32   `db:"station_id" json:"station_id"`
	Distance  float32 `db:"distance" json:"distance"`
}

type NotificationRepository

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

func NewNotificationRepository

func NewNotificationRepository(db *sqlxcache.DB) (rr *NotificationRepository)

func (*NotificationRepository) AddNotification

func (r *NotificationRepository) AddNotification(ctx context.Context, notification *data.Notification) (*data.Notification, error)

func (*NotificationRepository) DeleteByPostID

func (r *NotificationRepository) DeleteByPostID(ctx context.Context, postID int64) error

func (*NotificationRepository) MarkNotificationSeen

func (r *NotificationRepository) MarkNotificationSeen(ctx context.Context, userID int32, id int64) error

func (*NotificationRepository) QueryByUserID

func (r *NotificationRepository) QueryByUserID(ctx context.Context, userID int32) ([]*data.NotificationPost, error)

type PersistedModuleMeta

type PersistedModuleMeta struct {
	ID           int32         `db:"id" json:"id"`
	Key          string        `db:"key" json:"key"`
	Manufacturer uint32        `db:"manufacturer" json:"manufacturer"`
	Kinds        pq.Int32Array `db:"kinds" json:"kinds"`
	Version      pq.Int32Array `db:"version" json:"version"`
	Internal     bool          `db:"internal" json:"internal"`
}

type PersistedSensorMeta

type PersistedSensorMeta struct {
	ID                  int32           `db:"id" json:"id"`
	ModuleID            int32           `db:"module_id" json:"module_id"`
	SensorKey           string          `db:"sensor_key" json:"sensor_key"`
	FirmwareKey         string          `db:"firmware_key" json:"firmware_key"`
	FullKey             string          `db:"full_key" json:"full_key"`
	UnitOfMeasure       string          `db:"uom" json:"uom"`
	Ordering            int             `db:"ordering" json:"ordering"`
	Internal            bool            `db:"internal" json:"internal"`
	Strings             types.JSONText  `db:"strings" json:"strings"`
	Viz                 types.JSONText  `db:"viz" json:"viz"`
	Ranges              types.JSONText  `db:"ranges" json:"ranges"`
	Aliases             *pq.StringArray `db:"aliases" json:"aliases"`
	AggregationFunction *string         `db:"aggregation_function" json:"aggregationFunction"`
}

TODO Fix JSON keys

type ProjectRepository

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

func NewProjectRepository

func NewProjectRepository(db *sqlxcache.DB) (pr *ProjectRepository)

func (*ProjectRepository) AddDefaultProject

func (pr *ProjectRepository) AddDefaultProject(ctx context.Context, user *data.User) (project *data.Project, err error)

func (*ProjectRepository) AddProject

func (pr *ProjectRepository) AddProject(ctx context.Context, userID int32, project *data.Project) (*data.Project, error)

func (*ProjectRepository) AddStationToDefaultProjectMaybe

func (pr *ProjectRepository) AddStationToDefaultProjectMaybe(ctx context.Context, station *data.Station) error

func (*ProjectRepository) AddStationToProjectByID

func (pr *ProjectRepository) AddStationToProjectByID(ctx context.Context, projectID, stationID int32) error

func (*ProjectRepository) Delete

func (pr *ProjectRepository) Delete(outerCtx context.Context, projectID int32) error

func (*ProjectRepository) QueryByID

func (pr *ProjectRepository) QueryByID(ctx context.Context, projectID int32) (*data.Project, error)

func (*ProjectRepository) QueryProjectUser

func (pr *ProjectRepository) QueryProjectUser(ctx context.Context, userID, projectID int32) (*data.ProjectUser, error)

func (*ProjectRepository) QueryProjectsByStationIDForPermissions

func (pr *ProjectRepository) QueryProjectsByStationIDForPermissions(ctx context.Context, stationID int32) (projects []*data.Project, err error)

func (*ProjectRepository) QueryUserProjectRelationships

func (pr *ProjectRepository) QueryUserProjectRelationships(ctx context.Context, userID int32) (map[int32]*data.UserProjectRelationship, error)

type ProvisionRepository

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

func NewProvisionRepository

func NewProvisionRepository(db *sqlxcache.DB) (r *ProvisionRepository)

func (*ProvisionRepository) QueryOrCreateProvision

func (r *ProvisionRepository) QueryOrCreateProvision(ctx context.Context, deviceID, generationID []byte) (*data.Provision, error)

type QueriedEssential

type QueriedEssential struct {
	Stations []*data.EssentialStation
	Total    int32
}

type ReadingValue

type ReadingValue struct {
	Module *DataMetaModule `json:"module"`
	Sensor *DataMetaSensor `json:"sensor"`
	Value  float64         `json:"value"`
}

type RecordRepository

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

func NewRecordRepository

func NewRecordRepository(db *sqlxcache.DB, saveData bool) *RecordRepository

func (*RecordRepository) AddDataRecord

func (r *RecordRepository) AddDataRecord(ctx context.Context, p *data.Provision, i *data.Ingestion, dr *pb.DataRecord, pb []byte) (*data.DataRecord, *data.MetaRecord, error)

func (*RecordRepository) AddMetaRecord

func (r *RecordRepository) AddMetaRecord(ctx context.Context, p *data.Provision, i *data.Ingestion, recordNumber int64, dr *pb.DataRecord, pb []byte) (*data.MetaRecord, error)

func (*RecordRepository) AddSignedMetaRecord

func (r *RecordRepository) AddSignedMetaRecord(ctx context.Context, p *data.Provision, i *data.Ingestion, sr *pb.SignedRecord, dr *pb.DataRecord, pb []byte) (*data.MetaRecord, error)

func (*RecordRepository) QueryDevice

func (r *RecordRepository) QueryDevice(ctx context.Context, deviceId string, pageNumber, pageSize int) (page *RecordsPage, err error)

type RecordsPage

type RecordsPage struct {
	Data []*data.DataRecord
	Meta map[int64]*data.MetaRecord
}

type ResolvedRecord

type ResolvedRecord struct {
	ID       int64                       `json:"id"`
	Time     int64                       `json:"time"`
	Location []float64                   `json:"location"`
	Readings map[SensorKey]*ReadingValue `json:"-"`
}

type SavedBookmark

type SavedBookmark struct {
	ID           int64     `db:"id"`
	UserID       *int32    `db:"user_id"`
	Token        string    `db:"token"`
	Bookmark     string    `db:"bookmark"`
	CreatedAt    time.Time `db:"created_at"`
	ReferencedAt time.Time `db:"referenced_at"`
}

type SavedMedia

type SavedMedia struct {
	Key      string
	URL      string
	Size     int64
	MimeType string
}

type SensorAndModule

type SensorAndModule struct {
	Sensor *DataMetaSensor `json:"sensor"`
	Module *DataMetaModule `json:"module"`
}

type SensorAndModuleMeta

type SensorAndModuleMeta struct {
	Sensor *SensorMeta `json:"sensor"`
	Module *ModuleMeta `json:"module"`
}

type SensorKey

type SensorKey struct {
	ModuleIndex uint32 `json:"module_index"`
	SensorKey   string `json:"sensor_key"`
}

type SensorMeta

type SensorMeta struct {
	Key                 string                       `json:"key"`
	FullKey             string                       `json:"full_key"`
	FirmwareKey         string                       `json:"firmware_key"`
	UnitOfMeasure       string                       `json:"unit_of_measure"`
	Order               int                          `json:"order"`
	Ranges              []SensorRanges               `json:"ranges"`
	Internal            bool                         `json:"internal"`
	VizConfigs          []VizConfig                  `json:"viz"`
	Strings             map[string]map[string]string `json:"strings"`
	Aliases             []string                     `json:"aliases"`
	AggregationFunction string                       `json:"aggregationFunction"`
}

TODO Fix JSON keys

type SensorRanges

type SensorRanges struct {
	Minimum     float64 `json:"minimum"`
	Maximum     float64 `json:"maximum"`
	Constrained *bool   `json:"constrained"`
}

type SensorsRepository

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

func NewSensorsRepository

func NewSensorsRepository(db *sqlxcache.DB) (rr *SensorsRepository)

func (*SensorsRepository) AddSensor

func (r *SensorsRepository) AddSensor(ctx context.Context, key string) error

func (*SensorsRepository) QueryAllSensors

func (r *SensorsRepository) QueryAllSensors(ctx context.Context) (map[string]*data.Sensor, error)

func (*SensorsRepository) QueryQueryingSpec

func (r *SensorsRepository) QueryQueryingSpec(ctx context.Context) (*data.QueryingSpec, error)

type StationLayout

type StationLayout struct {
	Configurations []*data.StationConfiguration
	Modules        []*data.StationModule
	Sensors        []*data.ModuleSensor
}

type StationLayoutRepository

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

func NewStationLayoutRepository

func NewStationLayoutRepository(db *sqlxcache.DB) (rr *StationLayoutRepository, err error)

func (*StationLayoutRepository) QueryStationLayoutByDeviceID

func (r *StationLayoutRepository) QueryStationLayoutByDeviceID(ctx context.Context, deviceID []byte) (*StationLayout, error)

type StationRepository

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

func NewStationRepository

func NewStationRepository(db *sqlxcache.DB) (rr *StationRepository)

func (*StationRepository) AddStation

func (r *StationRepository) AddStation(ctx context.Context, adding *data.Station) (station *data.Station, err error)

func (*StationRepository) AssociateStations

func (r *StationRepository) AssociateStations(ctx context.Context, stationID, associatedStationID, priority int32) (err error)

func (*StationRepository) ClearAssociatedStations

func (r *StationRepository) ClearAssociatedStations(ctx context.Context, stationID int32) error

func (*StationRepository) Delete

func (sr *StationRepository) Delete(ctx context.Context, stationID int32) error

func (*StationRepository) FindOrCreateStationModel

func (r *StationRepository) FindOrCreateStationModel(ctx context.Context, ttnSchemaID int32, name string) (model *data.StationModel, err error)

func (*StationRepository) QueryAssociatedStations

func (r *StationRepository) QueryAssociatedStations(ctx context.Context, stationIDs []int32) (map[int32][]*AssociatedStation, error)

func (*StationRepository) QueryEssentialStations

func (sr *StationRepository) QueryEssentialStations(ctx context.Context, qp *EssentialQueryParams) (*QueriedEssential, error)

func (*StationRepository) QueryNearbyProjectStations

func (r *StationRepository) QueryNearbyProjectStations(ctx context.Context, projectID int32, location *data.Location) ([]*NearbyStation, error)

func (*StationRepository) QueryStationByArbitraryDeviceID

func (r *StationRepository) QueryStationByArbitraryDeviceID(ctx context.Context, deviceIdBytes []byte) (station *data.Station, err error)

func (*StationRepository) QueryStationByDeviceID

func (r *StationRepository) QueryStationByDeviceID(ctx context.Context, deviceIdBytes []byte) (station *data.Station, err error)

func (*StationRepository) QueryStationByID

func (r *StationRepository) QueryStationByID(ctx context.Context, id int32) (station *data.Station, err error)

func (*StationRepository) QueryStationByPhotoID

func (r *StationRepository) QueryStationByPhotoID(ctx context.Context, id int32) (station *data.Station, err error)

func (*StationRepository) QueryStationConfigurationByMetaID

func (r *StationRepository) QueryStationConfigurationByMetaID(ctx context.Context, metaRecordID int64) (*data.StationConfiguration, error)

func (*StationRepository) QueryStationFull

func (r *StationRepository) QueryStationFull(ctx context.Context, id int32) (*data.StationFull, error)

func (*StationRepository) QueryStationFullByOwnerID

func (r *StationRepository) QueryStationFullByOwnerID(ctx context.Context, id int32) ([]*data.StationFull, error)

func (*StationRepository) QueryStationFullByProjectID

func (r *StationRepository) QueryStationFullByProjectID(ctx context.Context, id int32) ([]*data.StationFull, error)

func (*StationRepository) QueryStationModuleByID

func (r *StationRepository) QueryStationModuleByID(ctx context.Context, id int32) (module *data.StationModule, err error)

func (*StationRepository) QueryStationModulesByHardwareID

func (r *StationRepository) QueryStationModulesByHardwareID(ctx context.Context, hardwareID []byte) ([]*data.StationModule, error)

func (*StationRepository) QueryStationModulesByMetaID

func (r *StationRepository) QueryStationModulesByMetaID(ctx context.Context, metaRecordID int64) ([]*data.StationModule, error)

func (*StationRepository) QueryStationProjectIds

func (r *StationRepository) QueryStationProjectIds(ctx context.Context, stationID int32) ([]int32, error)

func (*StationRepository) QueryStationSensors

func (sr *StationRepository) QueryStationSensors(ctx context.Context, stations []int32) (map[int32][]*StationSensor, error)

func (*StationRepository) QueryStationsByDeviceID

func (r *StationRepository) QueryStationsByDeviceID(ctx context.Context, deviceIdBytes []byte) (stations []*data.Station, err error)

func (*StationRepository) Search

func (sr *StationRepository) Search(ctx context.Context, query string) (*QueriedEssential, error)

func (*StationRepository) TryQueryStationByDeviceID

func (r *StationRepository) TryQueryStationByDeviceID(ctx context.Context, deviceIdBytes []byte) (station *data.Station, err error)

func (*StationRepository) UpdateOwner

func (r *StationRepository) UpdateOwner(ctx context.Context, station *data.Station) (err error)

func (*StationRepository) UpdatePhoto

func (r *StationRepository) UpdatePhoto(ctx context.Context, station *data.Station) (err error)

func (*StationRepository) UpdateStation

func (r *StationRepository) UpdateStation(ctx context.Context, station *data.Station) (err error)

func (*StationRepository) UpdateStationModelFromStatus

func (r *StationRepository) UpdateStationModelFromStatus(ctx context.Context, s *data.Station, rawStatus string) error

func (*StationRepository) UpdateStationModule

func (r *StationRepository) UpdateStationModule(ctx context.Context, module *data.StationModule) (*data.StationModule, error)

func (*StationRepository) UpsertConfiguration

func (r *StationRepository) UpsertConfiguration(ctx context.Context, configuration *data.StationConfiguration) (*data.StationConfiguration, error)

func (*StationRepository) UpsertModuleSensor

func (r *StationRepository) UpsertModuleSensor(ctx context.Context, sensor *data.ModuleSensor) (*data.ModuleSensor, error)

func (*StationRepository) UpsertStationModule

func (r *StationRepository) UpsertStationModule(ctx context.Context, module *data.StationModule) (*data.StationModule, error)

func (*StationRepository) UpsertVisibleConfiguration

func (r *StationRepository) UpsertVisibleConfiguration(ctx context.Context, stationID int32, configurationID int64) error

type StationSensor

type StationSensor struct {
	StationID       int32          `json:"stationId"`
	StationName     string         `json:"stationName"`
	StationLocation *data.Location `json:"stationLocation"`
	ModuleID        *string        `json:"moduleId"`
	ModuleKey       *string        `json:"moduleKey"`
	SensorID        *int64         `json:"sensorId"`
	SensorKey       *string        `json:"sensorKey"`
	SensorReadAt    *time.Time     `json:"sensorReadAt"`
	Order           int32          `json:"order"`
}

type StationSensorByOrder

type StationSensorByOrder []*StationSensor

func (StationSensorByOrder) Len

func (a StationSensorByOrder) Len() int

func (StationSensorByOrder) Less

func (a StationSensorByOrder) Less(i, j int) bool

func (StationSensorByOrder) Swap

func (a StationSensorByOrder) Swap(i, j int)

type StationSensorRow

type StationSensorRow struct {
	StationID       int32          `db:"station_id" json:"stationId"`
	StationName     string         `db:"station_name" json:"stationName"`
	StationLocation *data.Location `db:"station_location" json:"stationLocation"`
	ModuleID        *string        `db:"module_id" json:"moduleId"`
	ModuleKey       *string        `db:"module_key" json:"moduleKey"`
	SensorID        *int64         `db:"sensor_id" json:"sensorId"`
	SensorKey       *string        `db:"sensor_key" json:"sensorKey"`
	SensorReadAt    *time.Time     `db:"sensor_read_at" json:"sensorReadAt"`
}

type UserRepository

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

func NewUserRepository

func NewUserRepository(db *sqlxcache.DB) (r *UserRepository)

func (*UserRepository) Add

func (r *UserRepository) Add(ctx context.Context, user *data.User) error

func (*UserRepository) Delete

func (r *UserRepository) Delete(outerCtx context.Context, id int32) (err error)

func (*UserRepository) NewRecoveryToken

func (r *UserRepository) NewRecoveryToken(ctx context.Context, user *data.User, duration time.Duration) (*data.RecoveryToken, error)

func (*UserRepository) QueryAdminByEmail

func (r *UserRepository) QueryAdminByEmail(ctx context.Context, email string) (*data.User, error)

func (*UserRepository) QueryByEmail

func (r *UserRepository) QueryByEmail(ctx context.Context, email string) (*data.User, error)

func (*UserRepository) QueryByID

func (r *UserRepository) QueryByID(ctx context.Context, id int32) (*data.User, error)

func (*UserRepository) QueryMentionables

func (r *UserRepository) QueryMentionables(ctx context.Context, query string) ([]*data.User, error)

func (*UserRepository) Search

func (r *UserRepository) Search(ctx context.Context, query string) ([]*data.User, error)

type VersionMeta

type VersionMeta struct {
	ID      int64            `json:"id"`
	Station *DataMetaStation `json:"station"`
}

type VizConfig

type VizConfig struct {
	Name       string         `json:"name"`
	Disabled   bool           `json:"disabled"`
	MinimumGap int32          `json:"minimumGap"`
	Thresholds *VizThresholds `json:"thresholds"`
}

type VizThreshold

type VizThreshold struct {
	Label       map[string]string `json:"label"`
	KeyLabel    map[string]string `json:"keyLabel"`
	MapKeyLabel map[string]string `json:"mapKeyLabel"`
	PlainLabel  map[string]string `json:"plainLabel"`
	Value       float64           `json:"value"`
	Color       string            `json:"color"`
	Hidden      bool              `json:"hidden"`
	Start       float64           `json:"start"`
}

type VizThresholds

type VizThresholds struct {
	Label  map[string]string `json:"label"`
	Levels []*VizThreshold   `json:"levels"`
}

Jump to

Keyboard shortcuts

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