Fixed comments
This commit is contained in:
@@ -115,9 +115,22 @@ func GetDeviceData(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
deviceConnectedToContract := false
|
||||
for _, contractDeviceID := range contract.DeviceIDs {
|
||||
if deviceID == uint64(contractDeviceID) {
|
||||
deviceConnectedToContract = true
|
||||
}
|
||||
}
|
||||
|
||||
if !deviceConnectedToContract {
|
||||
log.Printf("Device %v is not connected to contract %v", deviceID, contractID )
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": "Device is not present int his contract"})
|
||||
return
|
||||
}
|
||||
|
||||
var deviceInfos []models.DeviceInfo
|
||||
// Modify your query to include filtering based on the contract's creation date
|
||||
query := shared.GetDb().Where("device_id = ?", deviceID).Where("start_time >= ? AND end_time <= ?", contract.StartTime,contract.EndTime)
|
||||
query := shared.GetDb().Where("device_id = ?", deviceID).Where("created_at >= ? AND created_at <= ?", contract.StartTime,contract.EndTime)
|
||||
|
||||
if err := query.Find(&deviceInfos).Error; err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
|
||||
Reference in New Issue
Block a user