Documentation ¶
Index ¶
- Constants
- Variables
- func AnnotationQuery(params simple_json.AnnotationQueryParams) middleware.Responder
- func Error(err error) middleware.Responder
- func MetricFindQuery(params simple_json.MetricFindQueryParams) middleware.Responder
- func MongoAddress() string
- func Query(params simple_json.QueryParams) middleware.Responder
- func TestDatasource(params simple_json.TestDatasourceParams) middleware.Responder
- type Cube
- type Timeserie
- func GetCubeCurrentTimeserie(dbName, cName string, options *v1.Query) ([]*Timeserie, error)
- func GetCubeFrequencyTimeserie(dbName, cName string, options *v1.Query) ([]*Timeserie, error)
- func GetCubeTemperatureTimeserie(dbName, cName string, options *v1.Query) ([]*Timeserie, error)
- func GetCubeTimeserie(dbName, cName string, options *v1.Query) ([]*Timeserie, error)
- func GetCubeVoltageTimeserie(dbName, cName string, options *v1.Query) ([]*Timeserie, error)
- func GetDevicesTimeserie(dbName, cName string, options *v1.Query) ([]*Timeserie, error)
- func GetLogrdbTimeserie(dbName, cName string, options *v1.Query) ([]*Timeserie, error)
- func GetProductsTimeserie(dbName, cName string, options *v1.Query) ([]*Timeserie, error)
- func GetUsersTimeserie(dbName, cName string, options *v1.Query) ([]*Timeserie, error)
Constants ¶
View Source
const ( EnvPrefix = "proxy" MongoAddressKey = "mongo.address" MongoAddressDefault = "localhost:27017" )
Default value
View Source
const ( ProductURL = "products/products" AertlistURL = "alert/alertlist" AlarmlistURL = "alert/alarmlist" DeviceURL = "devices/" LogrdbURL = "logrdb/" UsersURL = "users/users" CubeURL = "cube/cube_message" CubeVoltageURL = "cube/cube_message/voltage" CubeTemperatureURL = "cube/cube_message/temperature" CubeCurrentURL = "cube/cube_message/current" CubeFrequencyURL = "cube/cube_message/frequency" )
database url
Variables ¶
View Source
var ( // Adapter mongodb instance Adapter database.Adapter )
Functions ¶
func AnnotationQuery ¶
func AnnotationQuery(params simple_json.AnnotationQueryParams) middleware.Responder
AnnotationQuery POST /annotations
func MetricFindQuery ¶
func MetricFindQuery(params simple_json.MetricFindQueryParams) middleware.Responder
MetricFindQuery POST /search
func MongoAddress ¶
func MongoAddress() string
MongoAddress get mongo address from env(default:"localhost:27017")
func TestDatasource ¶
func TestDatasource(params simple_json.TestDatasourceParams) middleware.Responder
TestDatasource GET /
Types ¶
type Cube ¶
type Cube struct { Voltage int `json:"voltage,omitempty" bson:"voltage,omitempty"` Temperature int `json:"temperature,omitempty" bson:"temperature,omitempty"` Current int `json:"current,omitempty" bson:"current,omitempty"` Frequency int `json:"frequency,omitempty" bson:"frequency,omitempty"` Timestamp int64 `json:"timeStamp,omitempty" bson:"timeStamp,omitempty"` }
Cube ...
type Timeserie ¶
type Timeserie struct { Total int `json:"total,omitempty" bson:"total,omitempty"` Timestamp time.Time `json:"timestamp,omitempty" bson:"timestamp,omitempty"` }
Timeserie ...
func GetCubeCurrentTimeserie ¶
GetCubeCurrentTimeserie ...
func GetCubeFrequencyTimeserie ¶
GetCubeFrequencyTimeserie ...
func GetCubeTemperatureTimeserie ¶
GetCubeTemperatureTimeserie ...
func GetCubeTimeserie ¶
GetCubeTimeserie ...
func GetCubeVoltageTimeserie ¶
GetCubeVoltageTimeserie ...
func GetDevicesTimeserie ¶
GetDevicesTimeserie ...
func GetLogrdbTimeserie ¶
GetLogrdbTimeserie ...
func GetProductsTimeserie ¶
GetProductsTimeserie ...
db.getCollection('products').aggregate([
{ '$match':{ 'created_at': {'$gte': "2019-03-13T10:30:56Z", '$lte': "2019-03-14T09:25:50Z"} } }, { '$group': { '_id': { '$subtract': [ {'$toDate': '$created_at'}, { '$mod': [ {'$toLong': {'$toDate': '$created_at'}}, 60 * 60 * 24 * 1000 ] } ] }, 'total': {'$sum': 1} } }, { '$project': { '_id': 0, 'timestamp': '$_id', 'total': 1} }, { '$sort': { 'timestamp': 1 } }
])
Click to show internal directories.
Click to hide internal directories.