data

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: 30 Imported by: 1

Documentation

Index

Constants

View Source
const (
	MetaTypeName = "meta"
	DataTypeName = "data"
)
View Source
const (
	MentionNotification = "mention"
	ReplyNotification   = "reply"
)
View Source
const (
	MembershipAccepted = "Accepted"
	MembershipPending  = "Pending"
	MembershipRejected = "Rejected"
)
View Source
const (
	AverageFunctionName = "avg"
	MaximumFunctionName = "max"
)
View Source
const (
	FieldKitModelID = int32(1)
)

Variables

View Source
var (
	MemberRole = &Role{
		ID:              0,
		Name:            "Member",
		readOnlyProject: true,
	}
	AdministratorRole = &Role{
		ID:              1,
		Name:            "Administrator",
		readOnlyProject: false,
	}
	PublicRole = &Role{

		Name:            "Public",
		readOnlyProject: true,
	}
	AvailableRoles = []*Role{
		MemberRole,
		AdministratorRole,
	}
	Roles = []*Role{
		MemberRole,
		AdministratorRole,
		PublicRole,
	}
)
View Source
var (
	IncorrectPasswordError = errors.New("incorrect password")
	UnverifiedUserError    = errors.New("unverified user error")
)
View Source
var (
	RefreshTokenTtl = 365 * 24 * time.Hour
	LoginTokenTtl   = 24 * time.Hour

	RecoveryTokenTtl     = 1 * time.Hour
	ValidationTokenTtl   = 72 * time.Hour
	TransmissionTokenTtl = 2 * 24 * 365 * time.Hour
)
View Source
var (
	WindowNow = defaultNow
)
View Source
var (
	Windows = []*Window{
		{
			Duration: 24 * time.Hour * 7 * 4,
		},
		{
			Duration: 24 * time.Hour * 7,
		},
		{
			Duration: 24 * time.Hour * 3,
		},
		{
			Duration: 24 * time.Hour * 2,
		},
		{
			Duration: 24 * time.Hour,
		},
	}
)

Functions

func DecodeBinaryString

func DecodeBinaryString(s string) ([]byte, error)

func Logger

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

func Name

func Name(name string) string

func ParseBlocks

func ParseBlocks(s string) ([]int64, error)

func PostNotificationToMap

func PostNotificationToMap(n *Notification, p *DiscussionPost, u *User) map[string]interface{}

func QueryAsObject

func QueryAsObject(ctx context.Context, db *sqlxcache.DB, query string) ([]map[string]interface{}, error)

func ScanProjectUpdateWM

func ScanProjectUpdateWM(rows *sqlx.Rows) (interface{}, error)

func ScanStationIngestionWM

func ScanStationIngestionWM(rows *sqlx.Rows) (interface{}, error)

func SelectContextCustom

func SelectContextCustom(ctx context.Context, db *sqlxcache.DB, destination interface{}, mapFn MapFunc, query string, args ...interface{}) error

Types

type AggregatedDataSummary

type AggregatedDataSummary struct {
	StationID     int32      `db:"station_id"`
	Start         *time.Time `db:"start"`
	End           *time.Time `db:"end"`
	NumberSamples *int64     `db:"number_samples"`
}

type AggregatedReading

type AggregatedReading struct {
	ID            int64           `db:"id" json:"id"`
	StationID     int32           `db:"station_id" json:"stationId"`
	SensorID      int64           `db:"sensor_id" json:"sensorId"`
	ModuleID      int64           `db:"module_id" json:"moduleId"`
	Time          NumericWireTime `db:"time" json:"time"`
	Location      *Location       `db:"location" json:"location"`
	Value         float64         `db:"value" json:"value"`
	NumberSamples int32           `db:"nsamples" json:"nsamples"`
}

type AuthorOrUploaderWM

type AuthorOrUploaderWM struct {
	ID   int64  `json:"id"`
	Name string `json:"name"`
}

type Bookmark

type Bookmark struct {
	Version  int32           `json:"v"`
	Groups   []GroupBookmark `json:"g"`
	Stations []int32         `json:"s"`
}

{"v":1,"g":[ [[ [[159],[2],[-8640000000000000,8640000000000000],[],0,0] ]]],"s":[]}

func ParseBookmark

func ParseBookmark(s string) (*Bookmark, error)

func (*Bookmark) StationIDs

func (b *Bookmark) StationIDs() ([]int32, error)

func (*Bookmark) Vizes

func (b *Bookmark) Vizes() ([]*BookmarkViz, error)

type BookmarkSensor

type BookmarkSensor struct {
	StationID int32  `json:"station_id"`
	ModuleID  string `json:"module_id"`
	SensorID  int64  `json:"sensor_id"`
}

type BookmarkViz

type BookmarkViz struct {
	Start       time.Time         `json:"start"`
	End         time.Time         `json:"end"`
	ExtremeTime bool              `json:"extreme_time"`
	Sensors     []*BookmarkSensor `json:"sensors"`
}

type DataEvent

type DataEvent struct {
	ID          int64           `db:"id"`
	UserID      int32           `db:"user_id"`
	ProjectIDs  pq.Int64Array   `db:"project_ids"`
	StationIDs  pq.Int64Array   `db:"station_ids"`
	CreatedAt   time.Time       `db:"created_at"`
	UpdatedAt   time.Time       `db:"updated_at"`
	Start       time.Time       `db:"start_time"`
	End         time.Time       `db:"end_time"`
	Title       string          `db:"title"`
	Description string          `db:"description"`
	Context     *types.JSONText `db:"context"`
}

func (*DataEvent) GetContext

func (d *DataEvent) GetContext() (fields map[string]interface{}, err error)

func (*DataEvent) SetContext

func (d *DataEvent) SetContext(data interface{}) error

func (*DataEvent) StringBookmark

func (d *DataEvent) StringBookmark() *string

type DataEvents

type DataEvents struct {
	Events     []*DataEvent
	EventsByID map[int64]*DataEvent
	UsersByID  map[int32]*User
}

type DataExport

type DataExport struct {
	ID          int64          `db:"id"`
	Token       []byte         `db:"token"`
	UserID      int32          `db:"user_id"`
	Format      string         `db:"format"`
	CreatedAt   time.Time      `db:"created_at"`
	CompletedAt *time.Time     `db:"completed_at"`
	DownloadURL *string        `db:"download_url"`
	Size        *int32         `db:"size"`
	Progress    float64        `db:"progress"`
	Message     *string        `db:"message"`
	Args        types.JSONText `db:"args"`
}

type DataRecord

type DataRecord struct {
	ID           int64          `db:"id" json:"id"`
	ProvisionID  int64          `db:"provision_id" json:"provision_id"`
	Time         time.Time      `db:"time" json:"time"`
	Number       int64          `db:"number" json:"number"`
	MetaRecordID int64          `db:"meta_record_id" json:"meta_record_id"`
	Location     *Location      `db:"location" json:"location"`
	Data         types.JSONText `db:"raw" json:"raw"`
	PB           []byte         `db:"pb" json:"pb"`
}

func SanitizeDataRecord

func SanitizeDataRecord(r *DataRecord) *DataRecord

func (*DataRecord) GetData

func (d *DataRecord) GetData() (fields map[string]interface{}, err error)

func (*DataRecord) SetData

func (d *DataRecord) SetData(data interface{}) error

func (*DataRecord) Unmarshal

func (d *DataRecord) Unmarshal(r *pb.DataRecord) error

type DescribeLocations

type DescribeLocations struct {
	MapboxToken string
	// contains filtered or unexported fields
}

func NewDescribeLocations

func NewDescribeLocations(mapboxToken string, metrics *logging.Metrics) (ls *DescribeLocations)

func (*DescribeLocations) Describe

func (ls *DescribeLocations) Describe(ctx context.Context, l *Location) (ld *LocationDescription, err error)

func (*DescribeLocations) IsEnabled

func (ls *DescribeLocations) IsEnabled() bool

type DiscussionPost

type DiscussionPost struct {
	ID         int64           `db:"id"`
	UserID     int32           `db:"user_id"`
	ThreadID   *int64          `db:"thread_id"`
	ProjectID  *int32          `db:"project_id"`
	StationIDs pq.Int64Array   `db:"station_ids"`
	CreatedAt  time.Time       `db:"created_at"`
	UpdatedAt  time.Time       `db:"updated_at"`
	Body       string          `db:"body"`
	Context    *types.JSONText `db:"context"`
}

func (*DiscussionPost) GetContext

func (d *DiscussionPost) GetContext() (fields map[string]interface{}, err error)

func (*DiscussionPost) SetContext

func (d *DiscussionPost) SetContext(data interface{}) error

func (*DiscussionPost) StringBookmark

func (d *DiscussionPost) StringBookmark() *string

type Envelope

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

func (*Envelope) Coordinates

func (l *Envelope) Coordinates() [][]float64

func (*Envelope) Scan

func (l *Envelope) Scan(data interface{}) error

func (*Envelope) Value

func (l *Envelope) Value() (driver.Value, error)

type EssentialStation

type EssentialStation struct {
	ID                 int64      `db:"id"`
	Name               string     `db:"name"`
	DeviceID           []byte     `db:"device_id"`
	OwnerID            int32      `db:"owner_id"`
	OwnerName          string     `db:"owner_name"`
	OwnerEmail         string     `db:"owner_email"`
	CreatedAt          time.Time  `db:"created_at,omitempty"`
	UpdatedAt          time.Time  `db:"updated_at,omitempty"`
	RecordingStartedAt *time.Time `db:"recording_started_at"`
	MemoryUsed         *int32     `db:"memory_used"`
	MemoryAvailable    *int32     `db:"memory_available"`
	FirmwareNumber     *int32     `db:"firmware_number"`
	FirmwareTime       *int64     `db:"firmware_time"`
	Location           *Location  `db:"location"`
	LastIngestionAt    *time.Time `db:"last_ingestion_at,omitempty"`
}

type FieldNoteMedia

type FieldNoteMedia struct {
	ID          int64     `db:"id,omitempty"`
	StationID   int32     `db:"station_id"`
	UserID      int32     `db:"user_id"`
	ContentType string    `db:"content_type"`
	CreatedAt   time.Time `db:"created_at"`
	Key         string    `db:"key"`
	URL         string    `db:"url"`
}

type Firmware

type Firmware struct {
	ID             int32          `db:"id"`
	Time           time.Time      `db:"time"`
	Module         string         `db:"module"`
	Profile        string         `db:"profile"`
	Version        *string        `db:"version"`
	URL            string         `db:"url"`
	ETag           string         `db:"etag"`
	Meta           types.JSONText `db:"meta"`
	LogicalAddress *int64         `db:"logical_address"`
	Timestamp      *int64         `db:"timestamp"`
	Available      bool           `db:"available"`
	Hidden         bool           `db:"hidden"`
}

func (*Firmware) GetMeta

func (f *Firmware) GetMeta() (fields map[string]interface{}, err error)

type FollowersSummary

type FollowersSummary struct {
	ProjectID int32 `db:"project_id"`
	Followers int32 `db:"followers"`
}

type GroupBookmark

type GroupBookmark = [][]VizBookmark

type IncomingReading

type IncomingReading struct {
	StationID int32
	ModuleID  int64
	SensorID  int64
	SensorKey string
	Time      time.Time
	Value     float64
}

type IngestedWM

type IngestedWM struct {
	ID      int64 `json:"id"`
	Records int64 `json:"records"`
}

type Ingestion

type Ingestion struct {
	ID           int64         `db:"id"`
	Time         time.Time     `db:"time"`
	UploadID     string        `db:"upload_id"`
	UserID       int32         `db:"user_id"`
	DeviceID     []byte        `db:"device_id"`
	GenerationID []byte        `db:"generation"`
	Size         int64         `db:"size"`
	URL          string        `db:"url"`
	Type         string        `db:"type"`
	Blocks       Int64Range    `db:"blocks"`
	Flags        pq.Int64Array `db:"flags"`
}

type Int64Range

type Int64Range []int64

func (*Int64Range) Scan

func (a *Int64Range) Scan(src interface{}) error

Scan implements the sql.Scanner interface.

func (*Int64Range) ToInt64Array

func (a *Int64Range) ToInt64Array() []int64

func (*Int64Range) ToIntArray

func (a *Int64Range) ToIntArray() []int

func (Int64Range) Value

func (a Int64Range) Value() (driver.Value, error)

Value implements the driver.Valuer interface.

type Interestingness

type Interestingness float64

type InterestingnessFunction

type InterestingnessFunction interface {
	Calculate(value float64) Interestingness
	MoreThan(a, b Interestingness) bool
}

func NewMaximumInterestingessFunction

func NewMaximumInterestingessFunction() (fn InterestingnessFunction)

type Location

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

func NewLocation

func NewLocation(coordinates []float64) *Location

func (*Location) Coordinates

func (l *Location) Coordinates() []float64

func (*Location) Distance

func (l *Location) Distance(o *Location) float64

func (*Location) IsZero

func (l *Location) IsZero() bool

func (*Location) Latitude

func (l *Location) Latitude() float64

func (*Location) Longitude

func (l *Location) Longitude() float64

func (*Location) MarshalJSON

func (l *Location) MarshalJSON() ([]byte, error)

func (*Location) Scan

func (l *Location) Scan(data interface{}) error

func (*Location) String

func (l *Location) String() string

func (*Location) UnmarshalJSON

func (l *Location) UnmarshalJSON(data []byte) error

func (*Location) Valid

func (l *Location) Valid() bool

func (*Location) Value

func (l *Location) Value() (driver.Value, error)

type LocationDescription

type LocationDescription struct {
	OtherLandName  *string
	NativeLandName *string
}

type MapFunc

type MapFunc func(*sqlx.Rows) (interface{}, error)

type MaximumInterestingessFunction

type MaximumInterestingessFunction struct {
}

func (*MaximumInterestingessFunction) Calculate

func (*MaximumInterestingessFunction) MoreThan

type MetaRecord

type MetaRecord struct {
	ID          int64          `db:"id" json:"id"`
	ProvisionID int64          `db:"provision_id" json:"provision_id"`
	Time        time.Time      `db:"time" json:"time"`
	Number      int64          `db:"number" json:"number"`
	Data        types.JSONText `db:"raw" json:"raw"`
	PB          []byte         `db:"pb" json:"pb"`
}

func SanitizeMetaRecord

func SanitizeMetaRecord(r *MetaRecord) *MetaRecord

func (*MetaRecord) GetData

func (d *MetaRecord) GetData() (fields map[string]interface{}, err error)

func (*MetaRecord) SetData

func (d *MetaRecord) SetData(data interface{}) error

func (*MetaRecord) Unmarshal

func (d *MetaRecord) Unmarshal(r *pb.DataRecord) error

type ModuleSensor

type ModuleSensor struct {
	ID              int64      `db:"id" json:"id"`
	ModuleID        int64      `db:"module_id" json:"module_id"`
	ConfigurationID int64      `db:"configuration_id" json:"configuration_id"`
	Index           uint32     `db:"sensor_index" json:"sensor_index"`
	UnitOfMeasure   string     `db:"unit_of_measure" json:"unit_of_measure"`
	Name            string     `db:"name" json:"name"`
	ReadingValue    *float64   `db:"reading_last" json:"reading_last"`
	ReadingTime     *time.Time `db:"reading_time" json:"reading_time"`
}

type MultiPolygon

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

func (*MultiPolygon) Coordinates

func (l *MultiPolygon) Coordinates() [][][]float64

func (*MultiPolygon) Scan

func (l *MultiPolygon) Scan(data interface{}) error

type NativeLandInfo

type NativeLandInfo struct {
	Properties *NativeLandProperties `json:"properties"`
}

type NativeLandProperties

type NativeLandProperties struct {
	Name        string `json:"name"`
	FrenchName  string `json:"french_name"`
	Slug        string `json:"slug"`
	Description string `json:"description"`
}

type NativeLandResponse

type NativeLandResponse = []*NativeLandInfo

type Note

type Note struct {
	ID        int64     `db:"id,omitempty"`
	StationID int32     `db:"station_id"`
	CreatedAt time.Time `db:"created_at"`
	UpdatedAt time.Time `db:"updated_at"`
	AuthorID  int32     `db:"author_id"`
	Version   int64     `db:"version"`
	Key       *string   `db:"key"`
	Title     *string   `db:"title"`
	Body      *string   `db:"body"`
}
type NoteMediaLink struct {
	NoteID  int64 `db:"note_id,omitempty"`
	MediaID int64 `db:"media_id,omitempty"`
}

type Notification

type Notification struct {
	ID        int64     `db:"id" json:"id"`
	CreatedAt time.Time `db:"created_at": json:"createdAt"`
	UserID    int32     `db:"user_id": json:"userId"`
	PostID    *int64    `db:"post_id": json:"postId"`
	Key       string    `db:"key" json:"key"`
	Kind      string    `db:"kind" json:"kind"`
	Body      string    `db:"body" json:"body"` // ICU
	Seen      bool      `db:"seen" json:"seen"` // ICU
}

func NewMentionNotification

func NewMentionNotification(userID int32, postID int64) *Notification

func NewReplyNotification

func NewReplyNotification(userID int32, postID int64) *Notification

type NotificationPost

type NotificationPost struct {
	Notification
	ThreadID  *int64          `db:"thread_id"`
	ProjectID *int32          `db:"project_id"`
	Context   *types.JSONText `db:"context"`
	AuthorID  *int32          `db:"author_id"`
	Name      string          `db:"name"`
	Username  string          `db:"username"`
	MediaURL  *string         `db:"media_url"`
}

func (*NotificationPost) NotificationUserInfo

func (n *NotificationPost) NotificationUserInfo() *NotificationUser

func (*NotificationPost) StringBookmark

func (n *NotificationPost) StringBookmark() *string

func (*NotificationPost) ToMap

func (n *NotificationPost) ToMap() map[string]interface{}

type NotificationUser

type NotificationUser struct {
	ID    int32                  `json:"id"`
	Name  string                 `json:"name"`
	Photo *NotificationUserPhoto `json:"photo"`
}

func UserInfo

func UserInfo(user *User) *NotificationUser

type NotificationUserPhoto

type NotificationUserPhoto struct {
	URL *string `json:"url"`
}

type NowFunc

type NowFunc func() time.Time

type NumericWireTime

type NumericWireTime time.Time

func NumericWireTimePtr

func NumericWireTimePtr(t *time.Time) *NumericWireTime

func (*NumericWireTime) MarshalJSON

func (nw *NumericWireTime) MarshalJSON() ([]byte, error)

func (*NumericWireTime) Scan

func (nw *NumericWireTime) Scan(src interface{}) error

func (*NumericWireTime) Time

func (nw *NumericWireTime) Time() time.Time

func (NumericWireTime) Value

func (nw NumericWireTime) Value() (driver.Value, error)

type OtherLandFeature

type OtherLandFeature struct {
	Text      string `json:"text"`
	PlaceName string `json:"place_name"`
}

type OtherLandResponse

type OtherLandResponse struct {
	Features []*OtherLandFeature `json:"features"`
}

type PageOfDiscussion

type PageOfDiscussion struct {
	Posts     []*DiscussionPost
	PostsByID map[int64]*DiscussionPost
	UsersByID map[int32]*User
}

type PrivacyType

type PrivacyType int32
const (
	Private  PrivacyType = 0
	Public   PrivacyType = 1
	Obscured PrivacyType = 2
)

type Project

type Project struct {
	ID               int32           `db:"id,omitempty"`
	Name             string          `db:"name"`
	Description      string          `db:"description"`
	Goal             string          `db:"goal"`
	Location         string          `db:"location"`
	Tags             string          `db:"tags"`
	StartTime        *time.Time      `db:"start_time"`
	EndTime          *time.Time      `db:"end_time"`
	Privacy          PrivacyType     `db:"privacy"`
	MediaURL         *string         `db:"media_url"`
	MediaContentType *string         `db:"media_content_type"`
	Bounds           *types.JSONText `db:"bounds"`
	ShowStations     bool            `db:"show_stations"`
	CommunityRanking int32           `db:"community_ranking"`
}

type ProjectActivity

type ProjectActivity struct {
	ID        int64     `db:"id" json:"-"`
	CreatedAt time.Time `db:"created_at" json:"-"`
	ProjectID int32     `db:"project_id" json:"-"`
}

type ProjectAttribute

type ProjectAttribute struct {
	ID        int64  `db:"id"`
	ProjectID int32  `db:"project_id"`
	Name      string `db:"name"`
	Priority  int32  `db:"priority"`
}

type ProjectInvite

type ProjectInvite struct {
	ID           int32      `db:"id,omitempty"`
	UserID       int32      `db:"user_id"`
	ProjectID    int32      `db:"project_id"`
	RoleID       int32      `db:"role_id"`
	InvitedEmail string     `db:"invited_email"`
	InvitedTime  time.Time  `db:"invited_time"`
	AcceptedTime *time.Time `db:"accepted_time"`
	RejectedTime *time.Time `db:"rejected_time"`
	Token        Token      `db:"token" json:"token"`
}

func (*ProjectInvite) LookupRole

func (u *ProjectInvite) LookupRole() *Role

type ProjectStation

type ProjectStation struct {
	ProjectID int32 `db:"project_id"`
	StationID int32 `db:"station_id"`
}

type ProjectStationActivity

type ProjectStationActivity struct {
	ProjectActivity
	StationActivityID int64 `db:"station_activity_id" json:"-"`
}

type ProjectUpdate

type ProjectUpdate struct {
	ProjectActivity
	AuthorID int32  `db:"author_id" json:"-"`
	Body     string `db:"body" json:"body"`
}

type ProjectUpdateWM

type ProjectUpdateWM struct {
	ProjectActivity
	Author AuthorOrUploaderWM `json:"author"`
	Body   string             `db:"body" json:"body"`
}

type ProjectUser

type ProjectUser struct {
	UserID    int32 `db:"user_id"`
	ProjectID int32 `db:"project_id"`
	Role      int32 `db:"role"`
}

func (*ProjectUser) LookupRole

func (u *ProjectUser) LookupRole() *Role

func (*ProjectUser) RoleName

func (u *ProjectUser) RoleName() string

type ProjectUserAndProject

type ProjectUserAndProject struct {
	ProjectUser
	Project
}

type ProjectUserAndUser

type ProjectUserAndUser struct {
	ProjectUser
	User
}

type Provision

type Provision struct {
	ID           int64     `db:"id"`
	Created      time.Time `db:"created"`
	Updated      time.Time `db:"updated"`
	DeviceID     []byte    `db:"device_id"`
	GenerationID []byte    `db:"generation"`
}

type QueJob

type QueJob struct {
	Priority  int32     `db:"priority"`
	RunAt     time.Time `db:"run_at"`
	JobID     int64     `db:"job_id"`
	JobClass  string    `db:"job_type"`
	Args      string    `db:"args"`
	Errors    int32     `db:"error_count"`
	LastError *string   `db:"last_error"`
	Queue     string    `db:"queue"`
}

type Querier

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

func NewQuerier

func NewQuerier(db *sqlxcache.DB) *Querier

func (*Querier) SelectContextCustom

func (q *Querier) SelectContextCustom(ctx context.Context, destination interface{}, mapFn MapFunc, query string, args ...interface{}) error

type QueryingSpec

type QueryingSpec struct {
	Sensors map[int64]*SensorQueryingSpec `json:"sensors"`
}

type QueuedIngestion

type QueuedIngestion struct {
	ID           int64      `db:"id"`
	IngestionID  int64      `db:"ingestion_id"`
	Queued       time.Time  `db:"queued"`
	Attempted    *time.Time `db:"attempted"`
	Completed    *time.Time `db:"completed"`
	TotalRecords *int64     `db:"total_records"`
	OtherErrors  *int64     `db:"other_errors"`
	MetaErrors   *int64     `db:"meta_errors"`
	DataErrors   *int64     `db:"data_errors"`
}

type RecordRangeFlagEnum

type RecordRangeFlagEnum int
const (
	NoneRecordRangeFlag   RecordRangeFlagEnum = 0
	HiddenRecordRangeFlag RecordRangeFlagEnum = 1
)

type RecordRangeMeta

type RecordRangeMeta struct {
	ID        int64     `db:"id" json:"id"`
	StationID int32     `db:"station_id" json:"station_id"`
	StartTime time.Time `db:"start_time" json:"start_time"`
	EndTime   time.Time `db:"end_time" json:"end_time"`
	Flags     uint32    `db:"flags" json:"flags"`
}

type RecoveryToken

type RecoveryToken struct {
	Token   Token     `db:"token" json:"token"`
	UserID  int32     `db:"user_id" json:"user_id"`
	Expires time.Time `db:"expires" json:"expires"`
}

func NewRecoveryToken

func NewRecoveryToken(userID int32, length int, expires time.Time) (*RecoveryToken, error)

type RefreshToken

type RefreshToken struct {
	Token   Token     `db:"token" json:"token"`
	UserID  int32     `db:"user_id" json:"user_id"`
	Expires time.Time `db:"expires" json:"expires"`
}

func NewRefreshToken

func NewRefreshToken(userID int32, length int, expires time.Time) (*RefreshToken, error)

type Role

type Role struct {
	ID   int32
	Name string
	// contains filtered or unexported fields
}

func LookupRole

func LookupRole(id int32) *Role

func (*Role) IsProjectAdministrator

func (r *Role) IsProjectAdministrator() bool

func (*Role) IsProjectReadOnly

func (r *Role) IsProjectReadOnly() bool

type Sensor

type Sensor struct {
	ID                      int64  `db:"id"`
	Key                     string `db:"key"`
	InterestingnessPriority *int32 `db:"interestingness_priority"`
}

type SensorQueryingSpec

type SensorQueryingSpec struct {
	SensorID int64  `db:"sensor_id" json:"sensor_id"`
	Function string `db:"function" json:"function"`
}

type Station

type Station struct {
	ID                 int32      `db:"id,omitempty"`
	Name               string     `db:"name"`
	DeviceID           []byte     `db:"device_id"`
	OwnerID            int32      `db:"owner_id,omitempty"`
	ModelID            int32      `db:"model_id"`
	CreatedAt          time.Time  `db:"created_at,omitempty"`
	UpdatedAt          time.Time  `db:"updated_at,omitempty"`
	SyncedAt           *time.Time `db:"synced_at"`
	IngestionAt        *time.Time `db:"ingestion_at"`
	Battery            *float32   `db:"battery"`
	Location           *Location  `db:"location"`
	LocationName       *string    `db:"location_name"`
	RecordingStartedAt *time.Time `db:"recording_started_at"`
	MemoryUsed         *int32     `db:"memory_used"`
	MemoryAvailable    *int32     `db:"memory_available"`
	FirmwareNumber     *int32     `db:"firmware_number"`
	FirmwareTime       *int64     `db:"firmware_time"`
	PlaceOther         *string    `db:"place_other"`
	PlaceNative        *string    `db:"place_native"`
	PhotoID            *int32     `db:"photo_id"`
	Hidden             *bool      `db:"hidden"`
	Description        *string    `db:"description"`
	Status             *string    `db:"status"`
}

func (*Station) DeviceIDHex

func (s *Station) DeviceIDHex() string

func (*Station) ParseHttpReply

func (s *Station) ParseHttpReply(raw string) (*pb.HttpReply, error)

func (*Station) UpdateFromStatus

func (s *Station) UpdateFromStatus(ctx context.Context, raw string) error

type StationActivity

type StationActivity struct {
	ID        int64     `db:"id" json:"-"`
	CreatedAt time.Time `db:"created_at" json:"-"`
	StationID int32     `db:"station_id" json:"-"`
}

type StationArea

type StationArea struct {
	ID       int32        `db:"id,omitempty"`
	Name     string       `db:"name"`
	Geometry MultiPolygon `db:"geometry"`
}

type StationAttributeSlot

type StationAttributeSlot struct {
	AttributeID int64   `db:"attribute_id"`
	ProjectID   int32   `db:"project_id"`
	Name        string  `db:"name"`
	StringValue *string `db:"string_value"`
}

type StationConfiguration

type StationConfiguration struct {
	ID           int64     `db:"id" json:"id"`
	ProvisionID  int64     `db:"provision_id" json:"provision_id"`
	MetaRecordID *int64    `db:"meta_record_id" json:"meta_record_id"`
	SourceID     *int32    `db:"source_id" json:"source_id"`
	UpdatedAt    time.Time `db:"updated_at" json:"updated_at"`
}

type StationDeployed

type StationDeployed struct {
	StationActivity
	DeployedAt time.Time `db:"deployed_at"`
	Location   *Location `db:"location"`
}

type StationDeployedWM

type StationDeployedWM struct {
	StationActivity
	DeployedAt time.Time `db:"deployed_at" json:"deployed_at"`
	Location   Location  `db:"location" json:"location"`
}

type StationFull

type StationFull struct {
	Station         *Station
	Model           *StationModel
	Owner           *User
	Interestingness []*StationInterestingness
	Attributes      []*StationProjectNamedAttribute
	Areas           []*StationArea
	Ingestions      []*Ingestion
	Configurations  []*StationConfiguration
	Modules         []*StationModule
	Sensors         []*ModuleSensor
	DataSummary     *AggregatedDataSummary
	HasImages       bool
	ProjectIDs      []int32
}

type StationIngestion

type StationIngestion struct {
	StationActivity
	UploaderID      int32 `db:"uploader_id"`
	DataIngestionID int64 `db:"data_ingestion_id"`
	DataRecords     int64 `db:"data_records"`
	Errors          bool  `db:"errors"`
}

type StationIngestionWM

type StationIngestionWM struct {
	StationActivity
	Uploader AuthorOrUploaderWM `json:"uploader"`
	Data     IngestedWM         `json:"data"`
	Errors   bool               `json:"errors" db:"errors"`
}

type StationInterestingness

type StationInterestingness struct {
	ID              int64           `db:"id"`
	StationID       int32           `db:"station_id"`
	WindowSeconds   int32           `db:"window_seconds"`
	Interestingness Interestingness `db:"interestingness"`
	ReadingSensorID int64           `db:"reading_sensor_id"`
	ReadingModuleID int64           `db:"reading_module_id"`
	ReadingValue    float64         `db:"reading_value"`
	ReadingTime     time.Time       `db:"reading_time"`
}

func (*StationInterestingness) IsLive

func (si *StationInterestingness) IsLive() bool

type StationJob

type StationJob struct {
	Job *QueJob
}

type StationModel

type StationModel struct {
	ID                        int32  `db:"id,omitempty"`
	Name                      string `db:"name"`
	SchemaID                  *int32 `db:"ttn_schema_id"`
	OnlyVisibleViaAssociation bool   `db:"only_visible_via_association"`
}

type StationModule

type StationModule struct {
	ID              int64   `db:"id" json:"id"`
	ConfigurationID int64   `db:"configuration_id" json:"configuration_id"`
	HardwareID      []byte  `db:"hardware_id" json:"hardware_id"`
	Index           uint32  `db:"module_index" json:"module_index"`
	Position        uint32  `db:"position" json:"position"`
	Name            string  `db:"name" json:"name"`
	Manufacturer    uint32  `db:"manufacturer" json:"manufacturer"`
	Kind            uint32  `db:"kind" json:"kind"`
	Version         uint32  `db:"version" json:"version"`
	Flags           uint32  `db:"flags" json:"flags"`
	Label           *string `db:"label" json:"label"`
}

type StationProjectAttribute

type StationProjectAttribute struct {
	ID          int64  `db:"id"`
	StationID   int32  `db:"station_id"`
	AttributeID int64  `db:"attribute_id"`
	StringValue string `db:"string_value"`
}

type StationProjectNamedAttribute

type StationProjectNamedAttribute struct {
	ID          int64  `db:"id"`
	StationID   int32  `db:"station_id"`
	AttributeID int64  `db:"attribute_id"`
	StringValue string `db:"string_value"`
	ProjectID   int32  `db:"project_id"`
	Name        string `db:"name"`
	Priority    int32  `db:"priority"`
}

type TemporalPath

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

func (*TemporalPath) Coordinates

func (l *TemporalPath) Coordinates() [][]float64

func (*TemporalPath) Scan

func (l *TemporalPath) Scan(data interface{}) error

func (*TemporalPath) Value

func (l *TemporalPath) Value() (driver.Value, error)

type Token

type Token []byte

func NewToken

func NewToken(length int) (Token, error)

func (Token) MarshalText

func (t Token) MarshalText() (text []byte, err error)

MarshalText returns a base64-encoded slice of bytes.

func (*Token) Scan

func (id *Token) Scan(src interface{}) error

Scan sets the value of the Token based on an interface.

func (Token) String

func (t Token) String() string

String returns a base64-encoded string.

func (*Token) UnmarshalBinary

func (t *Token) UnmarshalBinary(data []byte) error

UnmarshalBinary sets the value of the Token based on a slice of bytes.

func (*Token) UnmarshalText

func (t *Token) UnmarshalText(text []byte) error

UnmarshalText sets the value of the Token based on a base64-encoded slice of bytes.

func (Token) Value

func (t Token) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type TwitterAccount

type TwitterAccount struct {
	TwitterAccountID int64  `db:"twitter_account_id"`
	ScreenName       string `db:"screen_name"`
	AccessToken      string `db:"access_token"`
	AccessSecret     string `db:"access_secret"`
}

type TwitterOAuth

type TwitterOAuth struct {
	SourceID      int32  `db:"source_id"`
	RequestToken  string `db:"request_token"`
	RequestSecret string `db:"request_secret"`
}

type User

type User struct {
	ID               int32     `db:"id,omitempty"`
	Name             string    `db:"name"`
	Username         string    `db:"username"`
	Email            string    `db:"email"`
	Password         []byte    `db:"password"`
	Valid            bool      `db:"valid"`
	Bio              string    `db:"bio"`
	MediaURL         *string   `db:"media_url"`
	MediaContentType *string   `db:"media_content_type"`
	Admin            bool      `db:"admin"`
	FirmwareTester   bool      `db:"firmware_tester"`
	FirmwarePattern  *string   `db:"firmware_pattern"`
	Taggable         bool      `db:"taggable"`
	CreatedAt        time.Time `db:"created_at"`
	UpdatedAt        time.Time `db:"updated_at"`
	TncDate          time.Time `db:"tnc_date"`
}

func (*User) CheckPassword

func (user *User) CheckPassword(password string) error

func (*User) NewToken

func (user *User) NewToken(now time.Time, refreshToken *RefreshToken) *jwtgo.Token

func (*User) SetPassword

func (user *User) SetPassword(password string) error

type UserProjectRelationship

type UserProjectRelationship struct {
	ProjectID  int32 `db:"project_id"`
	Following  bool  `db:"following"`
	MemberRole int32 `db:"member_role"`
}

func (*UserProjectRelationship) CanModify

func (r *UserProjectRelationship) CanModify() bool

func (*UserProjectRelationship) LookupRole

func (r *UserProjectRelationship) LookupRole() *Role

type ValidationToken

type ValidationToken struct {
	Token   Token     `db:"token" json:"token"`
	UserID  int32     `db:"user_id" json:"user_id"`
	Expires time.Time `db:"expires" json:"expires"`
}

func NewValidationToken

func NewValidationToken(userID int32, length int, expires time.Time) (*ValidationToken, error)

type VisibleConfiguration

type VisibleConfiguration struct {
	StationID       int32 `db:"station_id"`
	ConfigurationID int64 `db:"configuration_id"`
}

type VisibleStationConfiguration

type VisibleStationConfiguration struct {
	VisibleConfiguration
	StationConfiguration
}

type VizBookmark

type VizBookmark = []interface{} // [Stations, Sensors, [number, number], [[number, number], [number, number]] | [], ChartType, FastTime] | [];

type Window

type Window struct {
	Duration time.Duration
}

func (*Window) Includes

func (w *Window) Includes(test time.Time) bool

Jump to

Keyboard shortcuts

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