Documentation
¶
Index ¶
- Variables
- func GetApproximateLoc(lat, long float64) *h3.LatLng
- type CHService
- type Repository
- func (r *Repository) GetAvailableSignals(ctx context.Context, tokenID uint32, filter *model.SignalFilter) ([]string, error)
- func (r *Repository) GetDailyActivity(ctx context.Context, tokenID int, from, to time.Time, ...) ([]*model.DailyActivity, error)
- func (r *Repository) GetDataSummary(ctx context.Context, tokenID uint32, filter *model.SignalFilter) (*model.DataSummary, error)
- func (r *Repository) GetDeviceActivity(ctx context.Context, vehicleTokenID int, adMfrName string) (*model.DeviceActivity, error)
- func (r *Repository) GetEvents(ctx context.Context, tokenID int, from, to time.Time, ...) ([]*model.Event, error)
- func (r *Repository) GetSegments(ctx context.Context, tokenID int, from, to time.Time, ...) ([]*model.Segment, error)
- func (r *Repository) GetSignal(ctx context.Context, aggArgs *model.AggregatedSignalArgs) ([]*model.SignalAggregations, error)
- func (r *Repository) GetSignalLatest(ctx context.Context, latestArgs *model.LatestSignalsArgs) (*model.SignalCollection, error)
- type ValidationError
Constants ¶
This section is empty.
Variables ¶
var ManufacturerSourceTranslations = map[string]string{
"AutoPi": "autopi",
"Hashdog": "macaron",
"Ruptela": "ruptela",
}
TODO(elffjs): Get rid of this when we have device addresses in CH.
Functions ¶
func GetApproximateLoc ¶ added in v0.0.30
GetApproximateLoc returns the approximate location for the given latitude and longitude. The result is nil if some H3 library error occurs. We should probably be more concerned about this.
Types ¶
type CHService ¶ added in v0.0.13
type CHService interface {
GetAggregatedSignals(ctx context.Context, aggArgs *model.AggregatedSignalArgs) ([]*ch.AggSignal, error)
GetAggregatedSignalsForRanges(ctx context.Context, tokenID uint32, ranges []ch.TimeRange, globalFrom, globalTo time.Time, floatArgs []model.FloatSignalArgs, locationArgs []model.LocationSignalArgs) ([]*ch.AggSignalForRange, error)
GetLatestSignals(ctx context.Context, latestArgs *model.LatestSignalsArgs) ([]*vss.Signal, error)
GetAvailableSignals(ctx context.Context, tokenID uint32, filter *model.SignalFilter) ([]string, error)
GetSignalSummaries(ctx context.Context, tokenID uint32, filter *model.SignalFilter) ([]*model.SignalDataSummary, error)
GetEvents(ctx context.Context, subject string, from, to time.Time, filter *model.EventFilter) ([]*vss.Event, error)
GetEventCounts(ctx context.Context, subject string, from, to time.Time, eventNames []string) ([]*ch.EventCount, error)
GetEventCountsForRanges(ctx context.Context, subject string, ranges []ch.TimeRange, eventNames []string) ([]*ch.EventCountForRange, error)
GetEventSummaries(ctx context.Context, subject string) ([]*ch.EventSummary, error)
GetSegments(ctx context.Context, tokenID uint32, from, to time.Time, mechanism model.DetectionMechanism, config *model.SegmentConfig) ([]*model.Segment, error)
}
CHService is the interface for the ClickHouse service.
type Repository ¶
type Repository struct {
// contains filtered or unexported fields
}
Repository is the base repository for all repositories.
func NewRepository ¶
func NewRepository(chService CHService, settings config.Settings) (*Repository, error)
NewRepository creates a new base repository. clientCAs is optional and can be nil.
func (*Repository) GetAvailableSignals ¶ added in v0.0.21
func (r *Repository) GetAvailableSignals(ctx context.Context, tokenID uint32, filter *model.SignalFilter) ([]string, error)
GetAvailableSignals returns the available signals for the given tokenID and filter. If no signals are found, a nil slice is returned.
func (*Repository) GetDailyActivity ¶ added in v0.2.0
func (r *Repository) GetDailyActivity(ctx context.Context, tokenID int, from, to time.Time, mechanism model.DetectionMechanism, config *model.SegmentConfig, signalRequests []*model.SegmentSignalRequest, eventRequests []*model.SegmentEventRequest, timezone *string) ([]*model.DailyActivity, error)
GetDailyActivity returns one record per calendar day in the requested date range, including days with zero segments. mechanism must be ignitionDetection, frequencyAnalysis, or changePointDetection; idling, refuel, recharge return 400.
func (*Repository) GetDataSummary ¶ added in v0.1.22
func (r *Repository) GetDataSummary(ctx context.Context, tokenID uint32, filter *model.SignalFilter) (*model.DataSummary, error)
GetDataSummary returns the signal and event metadata for the given tokenID and filter.
func (*Repository) GetDeviceActivity ¶ added in v0.0.23
func (r *Repository) GetDeviceActivity(ctx context.Context, vehicleTokenID int, adMfrName string) (*model.DeviceActivity, error)
GetDeviceActivity returns device status activity level.
func (*Repository) GetEvents ¶ added in v0.1.19
func (r *Repository) GetEvents(ctx context.Context, tokenID int, from, to time.Time, filter *model.EventFilter) ([]*model.Event, error)
GetEvents returns the events for the given tokenID, from, to and filter.
func (*Repository) GetSegments ¶ added in v0.1.28
func (r *Repository) GetSegments(ctx context.Context, tokenID int, from, to time.Time, mechanism model.DetectionMechanism, config *model.SegmentConfig, signalRequests []*model.SegmentSignalRequest, eventRequests []*model.SegmentEventRequest, limit *int, after *time.Time) ([]*model.Segment, error)
GetSegments returns segments detected using the specified mechanism in the time range. Pagination: pass after (exclusive cursor = startTime of last segment from previous page) and limit (default 100, max 200). Segments are ordered by startTime ascending. When after is set, only segments with startTime > after are requested from CH.
func (*Repository) GetSignal ¶ added in v0.0.8
func (r *Repository) GetSignal(ctx context.Context, aggArgs *model.AggregatedSignalArgs) ([]*model.SignalAggregations, error)
GetSignal returns the aggregated signals for the given tokenID, interval, from, to and filter.
func (*Repository) GetSignalLatest ¶ added in v0.0.8
func (r *Repository) GetSignalLatest(ctx context.Context, latestArgs *model.LatestSignalsArgs) (*model.SignalCollection, error)
GetSignalLatest returns the latest signals for the given tokenID and filter.
type ValidationError ¶ added in v0.0.8
type ValidationError string
ValidationError is an error type for validation errors.
func (ValidationError) Error ¶ added in v0.0.8
func (v ValidationError) Error() string