models

package
v1.5.2 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2022 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultMessageBadRequest = Message{Message: "Bad Request"}

DefaultMessageBadRequest is the a default not found (404) message

View Source
var DefaultMessageInternalServerError = Message{Message: "Internal Server Error"}

DefaultMessageInternalServerError is the a default not found (404) message

View Source
var DefaultMessageNotFound = Message{Message: "Not Found"}

DefaultMessageNotFound is the a default not found (404) message

View Source
var DefaultMessageUnauthorized = Message{Message: "User is not authorized to use this resource"}

DefaultMessageUnauthorized is the a default unauthorized (403) message

View Source
var ListPlotConfigurationsSQL = `` /* 219-byte string literal not displayed */

ListPlotConfigurationsSQL is the base SQL statement for above functions

Functions

func AddTimeseriesToCollectionGroup

func AddTimeseriesToCollectionGroup(db *sqlx.DB, collectionGroupID *uuid.UUID, timeseriesID *uuid.UUID) error

AddTimeseriesToCollectionGroup adds a timeseries to a collection group

func ConstantMeasurement

func ConstantMeasurement(db *sqlx.DB, tsID *uuid.UUID, constantName string) (*ts.Measurement, error)

ConstantMeasurement returns a constant timeseries measurement for the same instrument by constant name

func CreateAlerts

func CreateAlerts(db *sqlx.DB, alertConfigIDS []uuid.UUID) error

CreateAlerts creates one or more new alerts

func CreateCalculation added in v1.4.0

func CreateCalculation(db *sqlx.DB, formula *Calculation) error

CreateCalculation accepts a single Calculation instance and attempts to create it in the database, returning an error if anything goes wrong.

Generating a UUID for the Calculation is not required. In the case that a Calculation is passed to this function **without** a set UUID field (i.e., `nil`), this function will set the UUID field to the one given to it by the database if the operation completes successfully. In the event that the function returns an error, the UUID field will remain unchanged.

func CreateInstrumentConstants

func CreateInstrumentConstants(db *sqlx.DB, tt []ts.Timeseries) ([]ts.Timeseries, error)

CreateInstrumentConstants creates many instrument constants from an array of instrument constants An InstrumentConstant is structurally the same as a timeseries and saved in the same tables

func CreateInstrumentGroupInstruments

func CreateInstrumentGroupInstruments(db *sqlx.DB, instrumentGroupID uuid.UUID, instrumentID uuid.UUID) error

CreateInstrumentGroupInstruments adds an instrument to an instrument group

func CreateOrUpdateInclinometerMeasurements

func CreateOrUpdateInclinometerMeasurements(db *sqlx.DB, im []ts.InclinometerMeasurementCollection, p *Profile, createDate time.Time) ([]ts.InclinometerMeasurementCollection, error)

CreateInclinometerMeasurements creates many inclinometer from an array of inclinometer If a inclinometer measurement already exists for a given timeseries_id and time, the values is updated

func CreateOrUpdateInstrumentStatus

func CreateOrUpdateInstrumentStatus(db *sqlx.DB, instrumentID *uuid.UUID, ss []InstrumentStatus) error

CreateOrUpdateInstrumentStatus creates a Instrument Status, updates value on conflict

func CreateOrUpdateTimeseriesMeasurements

func CreateOrUpdateTimeseriesMeasurements(db *sqlx.DB, mc []ts.MeasurementCollection) ([]ts.MeasurementCollection, error)

CreateOrUpdateTimeseriesMeasurements creates many timeseries from an array of timeseries If a timeseries measurement already exists for a given timeseries_id and time, the value is updated

func CreateOrUpdateTimeseriesMeasurementsTxn added in v1.5.2

func CreateOrUpdateTimeseriesMeasurementsTxn(txn *sqlx.Tx, mc []ts.MeasurementCollection) (*sqlx.Tx, error)

func CreateProjectTimeseries

func CreateProjectTimeseries(db *sqlx.DB, projectID *uuid.UUID, timeseriesID *uuid.UUID) error

CreateProjectTimeseries promotes a timeseries to the project level

func CreateTimeseries

func CreateTimeseries(db *sqlx.DB, tt []ts.Timeseries) ([]ts.Timeseries, error)

CreateTimeseries creates many timeseries from an array of timeseries

func CreateTimeseriesConstant

func CreateTimeseriesConstant(db *sqlx.DB, tsID *uuid.UUID, parameterName string, unitName string, value float64) error

CreateTimeseriesConstant creates timeseries constant

func DeleteCalculation added in v1.4.0

func DeleteCalculation(db *sqlx.DB, formulaID uuid.UUID) error

DeleteCalculation removes the `Calculation` with ID `formulaID` from the database, effectively dissociating it from the instrument in question.

func DeleteCollectionGroup

func DeleteCollectionGroup(db *sqlx.DB, projectID *uuid.UUID, collectionGroupID *uuid.UUID) error

DeleteCollectionGroup deletes a collection group and associated timeseries relationships using the id of the collection group

func DeleteFlagInstrument

func DeleteFlagInstrument(db *sqlx.DB, projectID, instrumentID *uuid.UUID) error

DeleteFlagInstrument changes delete flag to true

func DeleteFlagInstrumentGroup

func DeleteFlagInstrumentGroup(db *sqlx.DB, ID uuid.UUID) error

DeleteFlagInstrumentGroup sets the deleted field to true

func DeleteFlagProject

func DeleteFlagProject(db *sqlx.DB, id uuid.UUID) error

DeleteFlagProject sets deleted to true for a project

func DeleteInclinometerMeasurements

func DeleteInclinometerMeasurements(db *sqlx.DB, id *uuid.UUID, time time.Time) error

DeleteInclinometerMeasurements deletes a inclinometer Measurement

func DeleteInstrumentAlertConfig

func DeleteInstrumentAlertConfig(db *sqlx.DB, alertConfigID *uuid.UUID, instrumentID *uuid.UUID) error

DeleteInstrumentAlertConfig deletes an alert by ID

func DeleteInstrumentConstant

func DeleteInstrumentConstant(db *sqlx.DB, instrumentID *uuid.UUID, timeseriesID *uuid.UUID) error

DeleteInstrumentConstant removes a timeseries as an Instrument Constant; Does not delete underlying timeseries

func DeleteInstrumentGroupInstruments

func DeleteInstrumentGroupInstruments(db *sqlx.DB, instrumentGroupID uuid.UUID, instrumentID uuid.UUID) error

DeleteInstrumentGroupInstruments adds an instrument to an instrument group

func DeleteInstrumentNote

func DeleteInstrumentNote(db *sqlx.DB, id *uuid.UUID) error

DeleteInstrumentNote deletes an instrument note

func DeleteInstrumentStatus

func DeleteInstrumentStatus(db *sqlx.DB, id *uuid.UUID) error

DeleteInstrumentStatus deletes a status for an instrument

func DeletePlotConfiguration

func DeletePlotConfiguration(db *sqlx.DB, projectID *uuid.UUID, plotConfigID *uuid.UUID) error

DeletePlotConfiguration delete plot configuration for a project

func DeleteProjectTimeseries

func DeleteProjectTimeseries(db *sqlx.DB, projectID *uuid.UUID, timeseriesID *uuid.UUID) error

DeleteProjectTimeseries removes a timeseries from the project level; Does not delete underlying timeseries

func DeleteTimeserieMeasurements

func DeleteTimeserieMeasurements(db *sqlx.DB, id *uuid.UUID, time time.Time) error

DeleteTimeserieMeasurements deletes a timeseries Measurement

func DeleteTimeseries

func DeleteTimeseries(db *sqlx.DB, id *uuid.UUID) error

DeleteTimeseries deletes a timeseries and cascade deletes all measurements

func DeleteToken

func DeleteToken(db *sqlx.DB, profileID *uuid.UUID, tokenID *string) error

DeleteToken deletes a token by token_id

func DoCheckAlerts

func DoCheckAlerts(db *sqlx.DB) error

DoCheckAlerts checks for alert conditions; Creates alerts as needed

func GetInstrumentCount

func GetInstrumentCount(db *sqlx.DB) (int, error)

GetInstrumentCount returns the number of instruments in the database

func GetProjectCount

func GetProjectCount(db *sqlx.DB) (int, error)

GetProjectCount returns the number of projects in the database that are not deleted

func GetTimeseries

func GetTimeseries(db *sqlx.DB, id *uuid.UUID) (*ts.Timeseries, error)

GetTimeseries returns a single timeseries without measurements

func GetTimeseriesProjectMap

func GetTimeseriesProjectMap(db *sqlx.DB, timeseriesIDS []uuid.UUID) (map[uuid.UUID]uuid.UUID, error)

GetTimeseriesProjectMap returns a map of { timeseries_id: project_id, }

func Interpolate added in v1.5.2

func Interpolate(xs, ys []float64, x float64) (float64, error)

Interpolate takes two arrays for the corresponding x and y of each point, returning the predicted value of y at the position of x using linear interpolation

func JSONType

func JSONType(b []byte) string

JSONType is a helper to infer the JSON type from []byte; object or array https://stackoverflow.com/questions/55014001/check-if-json-is-object-or-array

func ListCalculationSlugs added in v1.4.0

func ListCalculationSlugs(db *sqlx.DB) ([]string, error)

func ListCollectionGroupSlugs

func ListCollectionGroupSlugs(db *sqlx.DB, projectID *uuid.UUID) ([]string, error)

ListCollectionGroupSlugs lists all collection group slugs for a project

func ListInclinometerMeasurementValues

func ListInclinometerMeasurementValues(db *sqlx.DB, timeseriesID *uuid.UUID, time time.Time, inclinometerConstant float64) ([]*ts.InclinometerMeasurementValues, error)

func ListInclinometerMeasurements

func ListInclinometerMeasurements(db *sqlx.DB, timeseriesID *uuid.UUID, tw *ts.TimeWindow) (*ts.InclinometerMeasurementCollection, error)

ListInclinometersMeasurements returns a timeseries with slice of inclinometer measurements populated

func ListInstrumentConstants

func ListInstrumentConstants(db *sqlx.DB, id *uuid.UUID) ([]ts.Timeseries, error)

ListInstrumentConstants lists constants for a given instrument id

func ListInstrumentGroupSlugs

func ListInstrumentGroupSlugs(db *sqlx.DB) ([]string, error)

ListInstrumentGroupSlugs lists used instrument group slugs in the database

func ListInstrumentGroupTimeseries

func ListInstrumentGroupTimeseries(db *sqlx.DB, instrumentGroupID *uuid.UUID) ([]ts.Timeseries, error)

ListInstrumentGroupTimeseries returns an array of timeseries for instruments that belong to an instrument_group

func ListInstrumentSlugs

func ListInstrumentSlugs(db *sqlx.DB) ([]string, error)

ListInstrumentSlugs lists used instrument slugs in the database

func ListInstrumentTimeseries

func ListInstrumentTimeseries(db *sqlx.DB, projectID *uuid.UUID, instrumentID *uuid.UUID) ([]ts.Timeseries, error)

ListInstrumentTimeseries returns an array of timeseries for an instrument

func ListPlotConfigurationSlugs

func ListPlotConfigurationSlugs(db *sqlx.DB) ([]string, error)

ListPlotConfigurationSlugs lists used instrument group slugs in the database

func ListProjectInstrumentNames

func ListProjectInstrumentNames(db *sqlx.DB, id *uuid.UUID) ([]string, error)

ListProjectInstrumentNames returns a slice of instrument names for a project

func ListProjectSlugs

func ListProjectSlugs(db *sqlx.DB) ([]string, error)

ListProjectSlugs returns a list of used slugs for projects

func ListProjectTimeseries

func ListProjectTimeseries(db *sqlx.DB, projectID *uuid.UUID) ([]ts.Timeseries, error)

ListProjectTimeseries lists all timeseries for a given project

func ListTimeseries

func ListTimeseries(db *sqlx.DB) ([]ts.Timeseries, error)

ListTimeseries lists all timeseries

func ListTimeseriesMeasurements

func ListTimeseriesMeasurements(db *sqlx.DB, timeseriesID *uuid.UUID, tw *ts.TimeWindow) (*ts.MeasurementCollection, error)

ListTimeseriesMeasurements returns a stored timeseries with slice of timeseries measurements populated

func ListTimeseriesSlugs

func ListTimeseriesSlugs(db *sqlx.DB) ([]string, error)

ListTimeseriesSlugs lists used timeseries slugs in the database

func ListTimeseriesSlugsForInstrument

func ListTimeseriesSlugsForInstrument(db *sqlx.DB, id *uuid.UUID) ([]string, error)

ListTimeseriesSlugsForInstrument lists used timeseries slugs for a given instrument

func ParseTOA5 added in v1.5.2

func ParseTOA5(filename string) ([][]string, error)

ParseTOA5 parses a Campbell Scientific TOA5 data file that is simlar to a csv. The unique properties of TOA5 are that the meatdata are stored in header of file (first 4 lines of csv)

func RemoveProjectMemberRole

func RemoveProjectMemberRole(db *sqlx.DB, projectID, profileID, roleID *uuid.UUID) error

RemoveProjectMemberRole removes a role from a user for a specific project

func RemoveTimeseriesFromCollectionGroup

func RemoveTimeseriesFromCollectionGroup(db *sqlx.DB, collectionGroupID *uuid.UUID, timeseriesID *uuid.UUID) error

RemoveTimeseriesFromCollectionGroup removes a timeseries from a collection group

func UnsubscribeProfileToAlerts

func UnsubscribeProfileToAlerts(db *sqlx.DB, alertConfigID *uuid.UUID, profileID *uuid.UUID) error

UnsubscribeProfileToAlerts subscribes a profile to an instrument alert

func UpdateCalculation added in v1.4.0

func UpdateCalculation(db *sqlx.DB, formula *Calculation) error

func UpdateTimeseries

func UpdateTimeseries(db *sqlx.DB, t *ts.Timeseries) (*ts.Timeseries, error)

UpdateTimeseries updates a timeseries

func UpdateTimeseriesMeasurements added in v1.5.1

func UpdateTimeseriesMeasurements(db *sqlx.DB, mc []ts.MeasurementCollection, tw *ts.TimeWindow) ([]ts.MeasurementCollection, error)

UpdateTimeseriesMeasurements updates many timeseries measurements, "overwriting" time and values to match paylaod

Types

type Action

type Action struct {
	Actor int       `json:"actor"`
	Type  string    `json:"action"`
	Time  time.Time `json:"action_time"`
}

Action captures an API action, including user, user's roles, type (GET, POST, etc.), and Time

type Alert

type Alert struct {
	Read           *bool     `json:"read,omitempty"`
	ID             uuid.UUID `json:"id"`
	AlertConfigID  uuid.UUID `json:"alert_config_id" db:"alert_config_id"`
	ProjectID      uuid.UUID `json:"project_id" db:"project_id"`
	InstrumentID   uuid.UUID `json:"instrument_id" db:"instrument_id"`
	ProjectName    string    `json:"project_name" db:"project_name"`
	InstrumentName string    `json:"instrument_name" db:"instrument_name"`
	Name           string    `json:"name"`
	Body           string    `json:"body"`
	CreateDate     time.Time `json:"create_date" db:"create_date"`
}

Alert is an alert, triggered by an AlertConfig evaluating to true

func DoAlertRead

func DoAlertRead(db *sqlx.DB, profileID *uuid.UUID, alertID *uuid.UUID) (*Alert, error)

DoAlertRead marks an alert as read for a profile

func DoAlertUnread

func DoAlertUnread(db *sqlx.DB, profileID *uuid.UUID, alertID *uuid.UUID) (*Alert, error)

DoAlertUnread marks an alert as unread for a profile

func GetMyAlert

func GetMyAlert(db *sqlx.DB, profileID *uuid.UUID, alertID *uuid.UUID) (*Alert, error)

GetMyAlert returns a single alert for which a profile is subscribed

func ListAlertsForInstrument

func ListAlertsForInstrument(db *sqlx.DB, instrumentID *uuid.UUID) ([]Alert, error)

ListAlertsForInstrument lists all alerts for a given instrument ID

func ListMyAlerts

func ListMyAlerts(db *sqlx.DB, profileID *uuid.UUID) ([]Alert, error)

ListMyAlerts returns all alerts for which a profile is subscribed to the AlertConfig

type AlertConfig

type AlertConfig struct {
	ID           uuid.UUID `json:"id"`
	InstrumentID uuid.UUID `json:"instrument_id" db:"instrument_id"`
	Name         string    `json:"name"`
	Body         string    `json:"body"`
	Formula      string    `json:"formula"`
	Schedule     string    `json:"schedule"`
	AuditInfo
}

AlertConfig is an alert configuration for an instrument

func CreateInstrumentAlertConfigs

func CreateInstrumentAlertConfigs(db *sqlx.DB, instrumentID *uuid.UUID, alertConfigs []AlertConfig) ([]AlertConfig, error)

CreateInstrumentAlertConfigs creates one or more new alert configurations

func GetAlertConfig

func GetAlertConfig(db *sqlx.DB, alertID *uuid.UUID) (*AlertConfig, error)

GetAlertConfig gets a single alert

func ListInstrumentAlertConfigs

func ListInstrumentAlertConfigs(db *sqlx.DB, instrumentID *uuid.UUID) ([]AlertConfig, error)

ListInstrumentAlertConfigs lists all alerts for a single instrument

func UpdateInstrumentAlertConfig

func UpdateInstrumentAlertConfig(db *sqlx.DB, instrumentID *uuid.UUID, alertConfigID *uuid.UUID, ac *AlertConfig) (*AlertConfig, error)

UpdateInstrumentAlertConfig updates an alert

type AlertConfigCollection

type AlertConfigCollection struct {
	Items []AlertConfig `json:"items"`
}

AlertConfigCollection holds one ore more alert items

func (*AlertConfigCollection) UnmarshalJSON

func (c *AlertConfigCollection) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the UnmarshalJSON Interface

type AlertSubscription

type AlertSubscription struct {
	ID            uuid.UUID `json:"id"`
	AlertConfigID uuid.UUID `json:"alert_config_id" db:"alert_config_id"`
	ProfileID     uuid.UUID `json:"profile_id" db:"profile_id"`
	AlertSubscriptionSettings
}

AlertSubscription is a profile subscription to an alert

func GetAlertSubscription

func GetAlertSubscription(db *sqlx.DB, alertConfigID *uuid.UUID, profileID *uuid.UUID) (*AlertSubscription, error)

GetAlertSubscription returns a AlertSubscription

func GetAlertSubscriptionByID

func GetAlertSubscriptionByID(db *sqlx.DB, id *uuid.UUID) (*AlertSubscription, error)

GetAlertSubscriptionByID returns an alert subscription

func ListMyAlertSubscriptions

func ListMyAlertSubscriptions(db *sqlx.DB, profileID *uuid.UUID) ([]AlertSubscription, error)

ListMyAlertSubscriptions returns all profile_alerts for a given profile ID

func SubscribeProfileToAlerts

func SubscribeProfileToAlerts(db *sqlx.DB, alertConfigID *uuid.UUID, profileID *uuid.UUID) (*AlertSubscription, error)

SubscribeProfileToAlerts subscribes a profile to an instrument alert

func UpdateMyAlertSubscription

func UpdateMyAlertSubscription(db *sqlx.DB, s *AlertSubscription) (*AlertSubscription, error)

UpdateMyAlertSubscription updates properties on a AlertSubscription

type AlertSubscriptionCollection

type AlertSubscriptionCollection struct {
	Items []AlertSubscription `json:"items"`
}

AlertSubscriptionCollection is a collection of AlertSubscription items

func (*AlertSubscriptionCollection) UnmarshalJSON

func (c *AlertSubscriptionCollection) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the UnmarshalJSON Interface for AlertSubscription

type AlertSubscriptionSettings

type AlertSubscriptionSettings struct {
	MuteUI     bool `json:"mute_ui" db:"mute_ui"`
	MuteNotify bool `json:"mute_notify" db:"mute_notify"`
}

AlertSubscriptionSettings holds all settings for an AlertSubscription

type AuditInfo

type AuditInfo struct {
	Creator    uuid.UUID  `json:"creator"`
	CreateDate time.Time  `json:"create_date" db:"create_date"`
	Updater    *uuid.UUID `json:"updater"`
	UpdateDate *time.Time `json:"update_date" db:"update_date"`
}

AuditInfo holds common information about object creator and updater

type AwareParameter

type AwareParameter struct {
	ID          uuid.UUID `json:"id"`
	Key         string    `json:"key"`
	ParameterID uuid.UUID `json:"parameter_id" db:"parameter_id"`
	UnitID      uuid.UUID `json:"unit_id" db:"unit_id"`
}

AwareParameter struct

func ListAwareParameters

func ListAwareParameters(db *sqlx.DB) ([]AwareParameter, error)

ListAwareParameters returns aware parameters

type AwarePlatformParameterConfig

type AwarePlatformParameterConfig struct {
	ProjectID       uuid.UUID             `json:"project_id" db:"project_id"`
	InstrumentID    uuid.UUID             `json:"instrument_id" db:"instrument_id"`
	AwareID         uuid.UUID             `json:"aware_id" db:"aware_id"`
	AwareParameters map[string]*uuid.UUID `json:"aware_parameters"`
}

AwarePlatformParameterConfig holds information about which parameters are "enabled" for given instrument(s) { projectID: <uuid4>, instrument_id: <uuid4>, aware_id: <uuid4>, aware_parameters: { <string>: <uuid4> } } aware_parameters is a map of <aware_parameter_key> : <timeseries_id>

func ListAwarePlatformParameterConfig

func ListAwarePlatformParameterConfig(db *sqlx.DB) ([]AwarePlatformParameterConfig, error)

ListAwarePlatformParameterConfig returns aware platform parameter configs

type Calculation added in v1.4.0

type Calculation struct {
	// ID of the Formula, to be used in future requests.
	ID uuid.UUID `json:"id"`

	// Associated instrument.
	InstrumentID uuid.UUID `json:"instrument_id"`

	// Parameter that this formula should be outputting.
	ParameterID uuid.UUID `json:"parameter_id"`

	// Unit that this formula should be outputting.
	UnitID uuid.UUID `json:"unit_id"`

	Slug        string `json:"slug"`
	FormulaName string `json:"formula_name"`
	Formula     string `json:"formula"`
}

func CalculationsFactory added in v1.4.0

func CalculationsFactory(rows *sqlx.Rows) ([]Calculation, error)

CalculationsFactory converts database rows to Calculation objects

func GetInstrumentCalculations added in v1.4.0

func GetInstrumentCalculations(db *sqlx.DB, instrument *Instrument) ([]Calculation, error)

GetInstrumentCalculations returns all formulas associated to a given instrument ID.

type CollectionGroup

type CollectionGroup struct {
	ID        uuid.UUID `json:"id"`
	ProjectID uuid.UUID `json:"project_id" db:"project_id"`
	Slug      string    `json:"slug"`
	Name      string    `json:"name"`
	AuditInfo
}

CollectionGroup holds information for entity collection_group

func CreateCollectionGroup

func CreateCollectionGroup(db *sqlx.DB, cg *CollectionGroup) (*CollectionGroup, error)

CreateCollectionGroup creates a new collection group

func ListCollectionGroups

func ListCollectionGroups(db *sqlx.DB, projectID *uuid.UUID) ([]CollectionGroup, error)

ListCollectionGroups lists all collection groups for a project

func UpdateCollectionGroup

func UpdateCollectionGroup(db *sqlx.DB, cg *CollectionGroup) (*CollectionGroup, error)

UpdateCollectionGroup updates an existing collection group's metadata

type CollectionGroupDetails

type CollectionGroupDetails struct {
	CollectionGroup
	Timeseries []cgdTsItem `json:"timeseries"`
}

CollectionGroupDetails holds same information as a CollectionGroup In Addition, contains array of structs; Each struct contains all fields for ts.Timeseries AND additional latest_value, latest_time

func GetCollectionGroupDetails

func GetCollectionGroupDetails(db *sqlx.DB, projectID *uuid.UUID, collectionGroupID *uuid.UUID) (*CollectionGroupDetails, error)

GetCollectionGroupDetails returns details for a single CollectionGroup

type CreateInstrumentsValidationResult

type CreateInstrumentsValidationResult struct {
	IsValid bool     `json:"is_valid"`
	Errors  []string `json:"errors"`
}

CreateInstrumentsValidationResult holds results of checking InstrumentCollection POST

func ValidateCreateInstruments

func ValidateCreateInstruments(db *sqlx.DB, instruments []Instrument) (CreateInstrumentsValidationResult, error)

ValidateCreateInstruments creates many instruments from an array of instruments

type DBTimeseries

type DBTimeseries struct {
	TimeseriesInfo
	Measurements        string  `json:"measurements" db:"measurements"`
	NextMeasurementLow  *string `json:"next_measurement_low" db:"next_measurement_low"`
	NextMeasurementHigh *string `json:"next_measurement_high" db:"next_measurement_high"`
}

Allows sending JSON Aggregated Data from the Database JSON Aggregated data not handled natively by sqlx

type DataLoggerFile added in v1.5.2

type DataLoggerFile struct {
	Head Head    `json:"head"`
	Data []Datum `json:"data"`
}

type Datum added in v1.5.2

type Datum struct {
	Time string    `json:"time"`
	No   int64     `json:"no"`
	Vals []float64 `json:"vals"`
}

type Domain

type Domain struct {
	ID          uuid.UUID `json:"id"`
	Group       string    `json:"group"`
	Value       string    `json:"value"`
	Description *string   `json:"description"`
}

Domain is a struct for returning all database domain values

func GetDomains

func GetDomains(db *sqlx.DB) ([]Domain, error)

GetDomains returns a UNION of all domain tables in the database

type EmailAlert

type EmailAlert struct {
	ID            uuid.UUID `json:"id"`
	AlertConfigID uuid.UUID `json:"alert_config_id"`
	EmailID       uuid.UUID `json:"profile_id"`
	MuteNotify    bool      `json:"mute_notify" db:"mute_notify"`
}

EmailAlert is an email subscription to an alert

type EmailAutocompleteResult

type EmailAutocompleteResult struct {
	ID       uuid.UUID `json:"id"`
	UserType string    `json:"user_type" db:"user_type"`
	Username *string   `json:"username"`
	Email    string    `json:"email"`
}

EmailAutocompleteResult stores search result in profiles and emails

func ListEmailAutocomplete

func ListEmailAutocomplete(db *sqlx.DB, str *string, limit *int) ([]EmailAutocompleteResult, error)

ListEmailAutocomplete returns search results for email autocomplete

type Environment added in v1.5.2

type Environment struct {
	StationName string `json:"station_name"`
	TableName   string `json:"table_name"`
	Model       string `json:"model"`
	SerialNo    string `json:"serial_no"`
	OSVersion   string `json:"os_version"`
	ProgName    string `json:"prog_name"`
}

type Field added in v1.5.2

type Field struct {
	Name     string `json:"name"`
	Type     string `json:"type"`
	Units    string `json:"units"`
	Process  string `json:"process"`
	Settable bool   `json:"settable"`
}
type Head struct {
	Transaction int64       `json:"transaction"`
	Signature   int64       `json:"signature"`
	Environment Environment `json:"environment"`
	Fields      []Field     `json:"fields"`
}

type Heartbeat

type Heartbeat struct {
	Time time.Time `json:"time"`
}

Heartbeat is a timestamp

func DoHeartbeat

func DoHeartbeat(db *sqlx.DB) (*Heartbeat, error)

DoHeartbeat does regular-interval tasks

func GetLatestHeartbeat

func GetLatestHeartbeat(db *sqlx.DB) (*Heartbeat, error)

GetLatestHeartbeat returns the most recent system heartbeat

func ListHeartbeats

func ListHeartbeats(db *sqlx.DB) ([]Heartbeat, error)

ListHeartbeats returns all system heartbeats

type IDAndSlug

type IDAndSlug struct {
	ID   uuid.UUID `json:"id"`
	Slug string    `json:"slug"`
}

IDAndSlug is a UUID4 and Slug representation of something

func CreateInstruments

func CreateInstruments(db *sqlx.DB, instruments []Instrument) ([]IDAndSlug, error)

CreateInstruments creates many instruments from an array of instruments

func CreateProjectBulk

func CreateProjectBulk(db *sqlx.DB, projects []Project) ([]IDAndSlug, error)

CreateProjectBulk creates one or more projects from an array of projects

type IDAndSlugCollection

type IDAndSlugCollection struct {
	Items []IDAndSlug `json:"items"`
}

IDAndSlugCollection is a collection of objects with ID and Slug properties

type InclinometerMeasurement

type InclinometerMeasurement struct {
	Time   time.Time      `json:"time"`
	Values types.JSONText `json:"values"`
}

func (InclinometerMeasurement) InclinometerLean

func (m InclinometerMeasurement) InclinometerLean() map[time.Time]types.JSONText

type InclinometerMeasurementCollectionCollection

type InclinometerMeasurementCollectionCollection struct {
	Items []ts.InclinometerMeasurementCollection
}

InclinometerMeasurementCollectionCollection is a collection of inclinometer measurement collections i.e an array of structs, each containing inclinometer measurements not necessarily from the same time series

func (*InclinometerMeasurementCollectionCollection) InclinometerTimeseriesIDs

func (cc *InclinometerMeasurementCollectionCollection) InclinometerTimeseriesIDs() []uuid.UUID

InclinometerTimeseriesIDs returns a slice of all timeseries IDs contained in the InclinometerMeasurementCollectionCollection

func (*InclinometerMeasurementCollectionCollection) UnmarshalJSON

UnmarshalJSON implements UnmarshalJSON interface

type InclinometerTimeseries

type InclinometerTimeseries struct {
	TimeseriesInfo
	Measurements        []InclinometerMeasurement `json:"measurements" db:"measurements"`
	NextMeasurementLow  *Measurement              `json:"next_measurement_low" db:"next_measurement_low"`
	NextMeasurementHigh *Measurement              `json:"next_measurement_high" db:"next_measurement_high"`
	TimeWindow          timeseries.TimeWindow     `json:"time_window"`
}

func ComputedInclinometerTimeseries

func ComputedInclinometerTimeseries(db *sqlx.DB, instrumentIDs []uuid.UUID, tw *timeseries.TimeWindow, interval *time.Duration) ([]InclinometerTimeseries, error)

ComputedInclinometerTimeseries returns computed and stored inclinometer timeseries for a specified array of instrument IDs

type Instrument

type Instrument struct {
	ID            uuid.UUID        `json:"id"`
	AwareID       *uuid.UUID       `json:"aware_id,omitempty"`
	Groups        []uuid.UUID      `json:"groups"`
	Constants     []uuid.UUID      `json:"constants"`
	AlertConfigs  []uuid.UUID      `json:"alert_configs"`
	StatusID      uuid.UUID        `json:"status_id" db:"status_id"`
	Status        string           `json:"status"`
	StatusTime    time.Time        `json:"status_time" db:"status_time"`
	Deleted       bool             `json:"-"`
	Slug          string           `json:"slug"`
	Name          string           `json:"name"`
	TypeID        uuid.UUID        `json:"type_id" db:"type_id"`
	Type          string           `json:"type"`
	Geometry      geojson.Geometry `json:"geometry,omitempty"`
	Station       *int             `json:"station"`
	StationOffset *int             `json:"offset" db:"station_offset"`
	ProjectID     *uuid.UUID       `json:"project_id" db:"project_id"`
	NIDID         *string          `json:"nid_id" db:"nid_id"`
	USGSID        *string          `json:"usgs_id" db:"usgs_id"`
	AuditInfo
}

Instrument is an instrument

func GetInstrument

func GetInstrument(db *sqlx.DB, id *uuid.UUID) (*Instrument, error)

GetInstrument returns a single instrument

func InstrumentsFactory

func InstrumentsFactory(rows *sqlx.Rows) ([]Instrument, error)

InstrumentsFactory converts database rows to Instrument objects

func ListInstrumentGroupInstruments

func ListInstrumentGroupInstruments(db *sqlx.DB, ID uuid.UUID) ([]Instrument, error)

ListInstrumentGroupInstruments returns a list of instrument group instruments for a given instrument

func ListInstruments

func ListInstruments(db *sqlx.DB) ([]Instrument, error)

ListInstruments returns an array of instruments from the database

func ListProjectInstruments

func ListProjectInstruments(db *sqlx.DB, id uuid.UUID) ([]Instrument, error)

ListProjectInstruments returns a slice of instruments for a project

func UpdateInstrument

func UpdateInstrument(db *sqlx.DB, i *Instrument) (*Instrument, error)

UpdateInstrument updates a single instrument

func UpdateInstrumentGeometry

func UpdateInstrumentGeometry(db *sqlx.DB, projectID *uuid.UUID, instrumentID *uuid.UUID, geom *geojson.Geometry, p *Profile) (*Instrument, error)

UpdateInstrumentGeometry updates instrument geometry property

func (*Instrument) AsSite

func (n *Instrument) AsSite() Site

AsSite returns an instrument represented as an OpenDCS Site

type InstrumentCollection

type InstrumentCollection struct {
	Items []Instrument
}

InstrumentCollection is a collection of Instrument items

func (InstrumentCollection) Shorten

Shorten returns an instrument collection with individual objects limited to ID and Struct fields

func (*InstrumentCollection) UnmarshalJSON

func (c *InstrumentCollection) UnmarshalJSON(b []byte) error

UnmarshalJSON implements UnmarshalJSON interface

type InstrumentGroup

type InstrumentGroup struct {
	ID              uuid.UUID  `json:"id"`
	Deleted         bool       `json:"-"`
	Slug            string     `json:"slug"`
	Name            string     `json:"name"`
	Description     string     `json:"description"`
	ProjectID       *uuid.UUID `json:"project_id" db:"project_id"`
	InstrumentCount int        `json:"instrument_count" db:"instrument_count"`
	TimeseriesCount int        `json:"timeseries_count" db:"timeseries_count"`
	AuditInfo
}

InstrumentGroup holds information for entity instrument_group

func CreateInstrumentGroup

func CreateInstrumentGroup(db *sqlx.DB, groups []InstrumentGroup) ([]InstrumentGroup, error)

CreateInstrumentGroup creates many instruments from an array of instruments

func GetInstrumentGroup

func GetInstrumentGroup(db *sqlx.DB, ID uuid.UUID) (*InstrumentGroup, error)

GetInstrumentGroup returns a single instrument group

func ListInstrumentGroups

func ListInstrumentGroups(db *sqlx.DB) ([]InstrumentGroup, error)

ListInstrumentGroups returns a list of instrument groups

func ListProjectInstrumentGroups

func ListProjectInstrumentGroups(db *sqlx.DB, id uuid.UUID) ([]InstrumentGroup, error)

ListProjectInstrumentGroups returns a list of instrument groups for a project

func UpdateInstrumentGroup

func UpdateInstrumentGroup(db *sqlx.DB, g *InstrumentGroup) (*InstrumentGroup, error)

UpdateInstrumentGroup updates an instrument group

type InstrumentGroupCollection

type InstrumentGroupCollection struct {
	Items []InstrumentGroup
}

InstrumentGroupCollection is a collection of Instrument items

func (InstrumentGroupCollection) Shorten

Shorten returns an instrument collection with individual objects limited to ID and Struct fields

func (*InstrumentGroupCollection) UnmarshalJSON

func (c *InstrumentGroupCollection) UnmarshalJSON(b []byte) error

UnmarshalJSON implements UnmarshalJSON interface Allows unpacking object or array of objects into array of objects

type InstrumentNote

type InstrumentNote struct {
	ID           uuid.UUID `json:"id"`
	InstrumentID uuid.UUID `json:"instrument_id" db:"instrument_id"`
	Title        string    `json:"title"`
	Body         string    `json:"body"`
	Time         time.Time `json:"time"`
	AuditInfo
}

InstrumentNote is a note about an instrument

func CreateInstrumentNote

func CreateInstrumentNote(db *sqlx.DB, notes []InstrumentNote) ([]InstrumentNote, error)

CreateInstrumentNote creates many instrument notes from an array of instrument notes

func GetInstrumentNote

func GetInstrumentNote(db *sqlx.DB, id *uuid.UUID) (*InstrumentNote, error)

GetInstrumentNote returns a single instrument note

func ListInstrumentInstrumentNotes

func ListInstrumentInstrumentNotes(db *sqlx.DB, instrumentID *uuid.UUID) ([]InstrumentNote, error)

ListInstrumentInstrumentNotes returns an array of instrument notes for a given instrument

func ListInstrumentNotes

func ListInstrumentNotes(db *sqlx.DB) ([]InstrumentNote, error)

ListInstrumentNotes returns an array of instruments from the database

func UpdateInstrumentNote

func UpdateInstrumentNote(db *sqlx.DB, n *InstrumentNote) (*InstrumentNote, error)

UpdateInstrumentNote updates a single instrument note

type InstrumentNoteCollection

type InstrumentNoteCollection struct {
	Items []InstrumentNote
}

InstrumentNoteCollection is a collection of Instrument Notes

func (*InstrumentNoteCollection) UnmarshalJSON

func (c *InstrumentNoteCollection) UnmarshalJSON(b []byte) error

UnmarshalJSON implements UnmarshalJSON interface Allows unpacking object or array of objects into array of objects

type InstrumentStatus

type InstrumentStatus struct {
	ID       uuid.UUID `json:"id"`
	Time     time.Time `json:"time"`
	StatusID uuid.UUID `json:"status_id" db:"status_id"`
	Status   string    `json:"status"`
}

InstrumentStatus is an instrument status

func GetInstrumentStatus

func GetInstrumentStatus(db *sqlx.DB, id *uuid.UUID) (*InstrumentStatus, error)

GetInstrumentStatus gets a single status

func ListInstrumentStatus

func ListInstrumentStatus(db *sqlx.DB, id *uuid.UUID) ([]InstrumentStatus, error)

ListInstrumentStatus returns all status values for an instrument

type InstrumentStatusCollection

type InstrumentStatusCollection struct {
	Items []InstrumentStatus
}

InstrumentStatusCollection is a collection of instrument status

func (*InstrumentStatusCollection) UnmarshalJSON

func (c *InstrumentStatusCollection) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the UnmarshalJSONinterface

type Measurement

type Measurement struct {
	Time  time.Time `json:"time"`
	Value float64   `json:"value"`
}

func (Measurement) Lean

func (m Measurement) Lean() map[time.Time]float64

type MeasurementCollection added in v1.5.1

type MeasurementCollection struct {
	TimeseriesID uuid.UUID     `json:"timeseries_id" db:"timeseries_id"`
	Items        []Measurement `json:"items"`
}

type Message

type Message struct {
	Message string `json:"message"`
}

Message is a response message; typically used for 400/500 level API responses

type PlotConfiguration

type PlotConfiguration struct {
	ID           uuid.UUID   `json:"id"`
	Name         string      `json:"name"`
	Slug         string      `json:"slug"`
	ProjectID    uuid.UUID   `json:"project_id" db:"project_id"`
	TimeseriesID []uuid.UUID `json:"timeseries_id" db:"timeseries_id"`
	AuditInfo
	PlotConfigurationSettings
}

PlotConfiguration holds information for entity PlotConfiguration

func CreatePlotConfiguration

func CreatePlotConfiguration(db *sqlx.DB, pc *PlotConfiguration) (*PlotConfiguration, error)

CreatePlotConfiguration add plot configuration for a project

func GetPlotConfiguration

func GetPlotConfiguration(db *sqlx.DB, projectID *uuid.UUID, plotconfigID *uuid.UUID) (*PlotConfiguration, error)

GetPlotConfiguration returns a single plot configuration

func ListPlotConfigurations

func ListPlotConfigurations(db *sqlx.DB, projectID *uuid.UUID) ([]PlotConfiguration, error)

ListPlotConfigurations returns a list of Plot groups

func PlotConfigFactory

func PlotConfigFactory(rows *sqlx.Rows) ([]PlotConfiguration, error)

PlotConfigFactory converts database rows to PlotConfiguration objects

func UpdatePlotConfiguration

func UpdatePlotConfiguration(db *sqlx.DB, pc *PlotConfiguration) (*PlotConfiguration, error)

UpdatePlotConfiguration update plot configuration for a project

type PlotConfigurationSettings added in v1.4.0

type PlotConfigurationSettings struct {
	ShowMasked       bool `json:"show_masked" db:"show_masked"`
	ShowNonValidated bool `json:"show_nonvalidated" db:"show_nonvalidated"`
	ShowComments     bool `json:"show_comments" db:"show_comments"`
}

PlotConfigurationSettings describes options for displaying the plot consistently. Specifically, whether to ignore data entries in a timeseries that have been masked, or whether to display user comments.

type Profile

type Profile struct {
	ID uuid.UUID `json:"id"`
	ProfileInfo
	Tokens  []TokenInfoProfile `json:"tokens"`
	IsAdmin bool               `json:"is_admin" db:"is_admin"`
	Roles   []string           `json:"roles"`
}

Profile is a user profile

func CreateProfile

func CreateProfile(db *sqlx.DB, n *ProfileInfo) (*Profile, error)

CreateProfile creates a new profile

func GetProfileFromEDIPI

func GetProfileFromEDIPI(db *sqlx.DB, e int) (*Profile, error)

GetProfileFromEDIPI returns a profile given an edipi

func GetProfileFromTokenID

func GetProfileFromTokenID(db *sqlx.DB, tokenID string) (*Profile, error)

GetProfileFromTokenID returns a profile given a token ID

func ProfilesFactory

func ProfilesFactory(rows *sqlx.Rows) ([]Profile, error)

ProfilesFactory converts database rows to Profile objects

type ProfileInfo

type ProfileInfo struct {
	EDIPI    int    `json:"-"`
	Username string `json:"username"`
	Email    string `json:"email"`
}

ProfileInfo is information necessary to construct a profile

type Project

type Project struct {
	ID                   uuid.UUID   `json:"id"`
	FederalID            *string     `json:"federal_id" db:"federal_id"`
	OfficeID             *uuid.UUID  `json:"office_id" db:"office_id"`
	Image                *string     `json:"image" db:"image"`
	Deleted              bool        `json:"-"`
	Slug                 string      `json:"slug"`
	Name                 string      `json:"name"`
	Timeseries           []uuid.UUID `json:"timeseries" db:"timeseries"`
	InstrumentCount      int         `json:"instrument_count" db:"instrument_count"`
	InstrumentGroupCount int         `json:"instrument_group_count" db:"instrument_group_count"`
	AuditInfo
}

Project is a project data structure

func GetProject

func GetProject(db *sqlx.DB, id uuid.UUID) (*Project, error)

GetProject returns a pointer to a project

func ListMyProjects

func ListMyProjects(db *sqlx.DB, profileID *uuid.UUID) ([]Project, error)

func ListProjects

func ListProjects(db *sqlx.DB) ([]Project, error)

ListProjects returns a slice of projects

func ProjectFactory

func ProjectFactory(rows *sqlx.Rows) ([]Project, error)

ProjectFactory converts database rows to Project objects

func UpdateProject

func UpdateProject(db *sqlx.DB, p *Project) (*Project, error)

UpdateProject updates a project

type ProjectCollection

type ProjectCollection struct {
	Projects []Project
}

ProjectCollection helps unpack unspecified JSON into an array of products

func (*ProjectCollection) UnmarshalJSON

func (c *ProjectCollection) UnmarshalJSON(b []byte) error

UnmarshalJSON implements UnmarshalJSON interface

type ProjectMembership

type ProjectMembership struct {
	ID        uuid.UUID `json:"id" db:"id"`
	ProfileID uuid.UUID `json:"profile_id" db:"profile_id"`
	Username  *string   `json:"username"`
	Email     string    `json:"email"`
	RoleID    uuid.UUID `json:"role_id" db:"role_id"`
	Role      string    `json:"role"`
}

ProjectMembership holds

func AddProjectMemberRole

func AddProjectMemberRole(db *sqlx.DB, projectID, profileID, roleID, grantedBy *uuid.UUID) (*ProjectMembership, error)

AddProjectMemberRole adds a role to a user for a specific project

func ListProjectMembers

func ListProjectMembers(db *sqlx.DB, projectID *uuid.UUID) ([]ProjectMembership, error)

ListProjectMembers lists users (profiles) who have permissions on a project and their role info

type SearchResult

type SearchResult struct {
	ID   uuid.UUID   `json:"id"`
	Type string      `json:"type"`
	Item interface{} `json:"item,omitempty"`
}

EmailAutocompleteResult stores search result in profiles and emails

func ProjectSearch

func ProjectSearch(db *sqlx.DB, str *string, limit *int) ([]SearchResult, error)

ProjectSearch returns search result for projects

type Shortener

type Shortener interface {
	// contains filtered or unexported methods
}

Shortener allows a shorter representation of an object. Typically, ID and Slug fields only

type Site

type Site struct {
	Elevation      string   `xml:"Elevation"`
	ElevationUnits string   `xml:"ElevationUnits"`
	Description    string   `xml:"Description"`
	SiteName       SiteName `xml:"SiteName"`
}

Site is an instrument, represented as an OpenDCS Site

func ListOpendcsSites

func ListOpendcsSites(db *sqlx.DB) ([]Site, error)

ListOpendcsSites returns an array of instruments from the database And formats them as OpenDCS Sites

type SiteName

type SiteName struct {
	ID       uuid.UUID `xml:",chardata"`
	NameType string    `xml:",attr"`
}

SiteName is SiteName

type Telemetry

type Telemetry struct {
	ID       uuid.UUID
	TypeID   string
	TypeSlug string
	TypeName string
}

Telemetry struct

type Timeseries

type Timeseries struct {
	TimeseriesInfo
	Measurements        []Measurement         `json:"measurements" db:"measurements"`
	NextMeasurementLow  *Measurement          `json:"next_measurement_low" db:"next_measurement_low"`
	NextMeasurementHigh *Measurement          `json:"next_measurement_high" db:"next_measurement_high"`
	TimeWindow          timeseries.TimeWindow `json:"time_window"`
}

func AllTimeseriesWithMeasurements added in v1.5.1

func AllTimeseriesWithMeasurements(db *sqlx.DB, instrumentIDs []uuid.UUID, tw *timeseries.TimeWindow, interval *time.Duration) ([]Timeseries, error)

AllTimeseriesWithMeasurements returns all stored and computed timeseries for a specified array of instrument IDs

func ComputedTimeseriesWithMeasurements added in v1.5.1

func ComputedTimeseriesWithMeasurements(db *sqlx.DB, timeseriesID *uuid.UUID, instrumentID *uuid.UUID, tw *timeseries.TimeWindow, interval *time.Duration) ([]Timeseries, error)

ComputedTimeseriesWithMeasurements returns computed for a specified instrument ID

func (Timeseries) AggregateCarryForward added in v1.5.1

func (ts Timeseries) AggregateCarryForward(w timeseries.TimeWindow, allTimes []time.Time) (Timeseries, error)

AggregateCarryForward creates an array of Measurments for a timeserires given an aggregate array of times This assumes that the provided aggregate set of times does not have any repeating times This algorithm will remember the last exisiting Measurement value in the Timeseries

func (Timeseries) AggregateInterpolate added in v1.5.1

func (ts Timeseries) AggregateInterpolate(w timeseries.TimeWindow, allTimes []time.Time) (Timeseries, error)

AggregateInterpolate creates an array of Measurments for a timeseries given an aggregate array of times. This assumes that the provided aggregate set of times does not have any repeating times. This algorithm will predict Measurement values given an x postion to predict and xy values of the neighboring points

func (*Timeseries) Calculate

func (ts *Timeseries) Calculate(variableMap map[time.Time]map[string]interface{}, interval *time.Duration) error

func (*Timeseries) CalculateAggregate added in v1.5.1

func (ts *Timeseries) CalculateAggregate(variableMap map[time.Time]map[string]interface{}) error

CalculateAggregate computes aggregate, possibly irregular intervals of all timeseires The provided variableMap should include multiple variables for each key (time) provided

func (Timeseries) RegularizeCarryForward

func (ts Timeseries) RegularizeCarryForward(w timeseries.TimeWindow, d time.Duration) (Timeseries, error)

RegularizeCarryForward converts potentially irregular timeseries measurements into a regular interval timeseries over the time window w with measurements spaced at interval d Missing values are filled-in using a carry forward algorithm (use previous known value in time for missing values)

func (Timeseries) RegularizeInterpolate

func (ts Timeseries) RegularizeInterpolate(w timeseries.TimeWindow, d time.Duration) (Timeseries, error)

func (*Timeseries) ResampleTimeseriesMeasurements added in v1.5.1

func (ts *Timeseries) ResampleTimeseriesMeasurements(w *timeseries.TimeWindow, d *time.Duration) (Timeseries, error)

ResampleTimeseriesMeasurements provides values at a fixed, regularized interval based a provided duration These resampled values are interpolated from the nearest points in the aggregate calculation's curve

type TimeseriesCollection

type TimeseriesCollection struct {
	Items []ts.Timeseries
}

TimeseriesCollection is a collection of Timeseries items

func (*TimeseriesCollection) UnmarshalJSON

func (c *TimeseriesCollection) UnmarshalJSON(b []byte) error

UnmarshalJSON implements UnmarshalJSON interface

type TimeseriesInfo

type TimeseriesInfo struct {
	TimeseriesID uuid.UUID `json:"timeseries_id" db:"timeseries_id"`
	InstrumentID uuid.UUID `json:"instrument_id" db:"instrument_id"`
	Variable     string    `json:"variable" db:"variable"`
	IsComputed   bool      `json:"is_computed" db:"is_computed"`
	Formula      *string   `json:"formula" db:"formula"`
}

type TimeseriesMeasurementCollectionCollection

type TimeseriesMeasurementCollectionCollection struct {
	Items []ts.MeasurementCollection
}

TimeseriesMeasurementCollectionCollection is a collection of timeseries measurement collections i.e an array of structs, each containing timeseries measurements not necessarily from the same time series

func (*TimeseriesMeasurementCollectionCollection) TimeseriesIDs

func (cc *TimeseriesMeasurementCollectionCollection) TimeseriesIDs() []uuid.UUID

TimeseriesIDs returns a slice of all timeseries IDs contained in the MeasurementCollectionCollection

func (*TimeseriesMeasurementCollectionCollection) UnmarshalJSON

func (cc *TimeseriesMeasurementCollectionCollection) UnmarshalJSON(b []byte) error

UnmarshalJSON implements UnmarshalJSON interface

type Token

type Token struct {
	SecretToken string `json:"secret_token"`
	TokenInfo
}

Token includes all TokenInfo and the actual token string generated for a user this is only returned the first time a token is generated

func CreateProfileToken

func CreateProfileToken(db *sqlx.DB, profileID *uuid.UUID) (*Token, error)

CreateProfileToken creates a secret token and stores the HASH (not the actual token) to the database. The return payload of this function is the first and last time you'll see the raw token unless the user writes it down or stores it somewhere safe.

type TokenInfo

type TokenInfo struct {
	ID        uuid.UUID `json:"-"`
	TokenID   string    `json:"token_id" db:"token_id"`
	ProfileID uuid.UUID `json:"profile_id" db:"profile_id"`
	Issued    time.Time `json:"issued"`
	Hash      string    `json:"-"`
}

TokenInfo represents the information held in the database about a token

func GetTokenInfoByTokenID

func GetTokenInfoByTokenID(db *sqlx.DB, tokenID *string) (*TokenInfo, error)

GetTokenInfoByTokenID returns a single token by token id

type TokenInfoProfile

type TokenInfoProfile struct {
	TokenID string    `json:"token_id" db:"token_id"`
	Issued  time.Time `json:"issued"`
}

TokenInfoProfile is token information embedded in Profile

type Unit

type Unit struct {
	ID           uuid.UUID `json:"id"`
	Name         string    `json:"name"`
	Abbreviation string    `json:"abbreviation"`
	UnitFamilyID uuid.UUID `json:"unit_family_id" db:"unit_family_id"`
	UnitFamily   string    `json:"unit_family" db:"unit_family"`
	MeasureID    uuid.UUID `json:"measure_id" db:"measure_id"`
	Measure      string    `json:"measure"`
}

Unit is a unit data structure

func ListUnits

func ListUnits(db *sqlx.DB) ([]Unit, error)

ListUnits returns a slice of units

Jump to

Keyboard shortcuts

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