@@ -162,13 +162,13 @@ func (a *TsExtractor) populateNumericTSDataIntoS3(
162
162
a .logger .Debugf ("Thing %s - Property %s - %d values\n " , thingID , propertyID , response .CountValues )
163
163
sampleCount += response .CountValues
164
164
165
- propertyName := extractPropertyName (thing , propertyID )
165
+ propertyName , propertyType := extractPropertyNameAndType (thing , propertyID )
166
166
167
167
for i := 0 ; i < len (response .Times ); i ++ {
168
168
169
169
ts := response .Times [i ]
170
170
value := response .Values [i ]
171
- samples = append (samples , composeRow (ts , thingID , thing .Name , propertyID , propertyName , strconv .FormatFloat (value , 'f' , - 1 , 64 )))
171
+ samples = append (samples , composeRow (ts , thingID , thing .Name , propertyID , propertyName , propertyType , strconv .FormatFloat (value , 'f' , - 1 , 64 )))
172
172
}
173
173
}
174
174
@@ -183,26 +183,29 @@ func (a *TsExtractor) populateNumericTSDataIntoS3(
183
183
return nil
184
184
}
185
185
186
- func composeRow (ts time.Time , thingID string , thingName string , propertyID string , propertyName string , value string ) []string {
187
- row := make ([]string , 6 )
186
+ func composeRow (ts time.Time , thingID string , thingName string , propertyID string , propertyName string , propertyType string , value string ) []string {
187
+ row := make ([]string , 7 )
188
188
row [0 ] = ts .UTC ().Format (time .RFC3339 )
189
189
row [1 ] = thingID
190
190
row [2 ] = thingName
191
191
row [3 ] = propertyID
192
192
row [4 ] = propertyName
193
- row [5 ] = value
193
+ row [5 ] = propertyType
194
+ row [6 ] = value
194
195
return row
195
196
}
196
197
197
- func extractPropertyName (thing iotclient.ArduinoThing , propertyID string ) string {
198
+ func extractPropertyNameAndType (thing iotclient.ArduinoThing , propertyID string ) ( string , string ) {
198
199
propertyName := ""
200
+ propertyType := ""
199
201
for _ , prop := range thing .Properties {
200
202
if prop .Id == propertyID {
201
203
propertyName = prop .Name
204
+ propertyType = prop .Type
202
205
break
203
206
}
204
207
}
205
- return propertyName
208
+ return propertyName , propertyType
206
209
}
207
210
208
211
func isStringProperty (ptype string ) bool {
@@ -258,7 +261,7 @@ func (a *TsExtractor) populateStringTSDataIntoS3(
258
261
a .logger .Debugf ("Thing %s - String Property %s - %d values\n " , thingID , propertyID , response .CountValues )
259
262
sampleCount += response .CountValues
260
263
261
- propertyName := extractPropertyName (thing , propertyID )
264
+ propertyName , propertyType := extractPropertyNameAndType (thing , propertyID )
262
265
263
266
for i := 0 ; i < len (response .Times ); i ++ {
264
267
@@ -267,7 +270,7 @@ func (a *TsExtractor) populateStringTSDataIntoS3(
267
270
if value == nil {
268
271
continue
269
272
}
270
- samples = append (samples , composeRow (ts , thingID , thing .Name , propertyID , propertyName , interfaceToString (value )))
273
+ samples = append (samples , composeRow (ts , thingID , thing .Name , propertyID , propertyName , propertyType , interfaceToString (value )))
271
274
}
272
275
}
273
276
@@ -318,7 +321,7 @@ func (a *TsExtractor) populateRawTSDataIntoS3(
318
321
a .logger .Infof ("Thing %s - Query %s Property %s - %d values\n " , thingID , response .Query , propertyID , response .CountValues )
319
322
sampleCount += response .CountValues
320
323
321
- propertyName := extractPropertyName (thing , propertyID )
324
+ propertyName , propertyType := extractPropertyNameAndType (thing , propertyID )
322
325
323
326
for i := 0 ; i < len (response .Times ); i ++ {
324
327
@@ -327,7 +330,7 @@ func (a *TsExtractor) populateRawTSDataIntoS3(
327
330
if value == nil {
328
331
continue
329
332
}
330
- samples = append (samples , composeRow (ts , thingID , thing .Name , propertyID , propertyName , interfaceToString (value )))
333
+ samples = append (samples , composeRow (ts , thingID , thing .Name , propertyID , propertyName , propertyType , interfaceToString (value )))
331
334
}
332
335
}
333
336
0 commit comments