Fixed comments
This commit is contained in:
@@ -16,7 +16,7 @@ func GetLatestContracts(c *gin.Context) {
|
||||
// Get limit and offset from query parameter with defaults
|
||||
limitStr := c.DefaultQuery("limit", "99999999999999999999999999999999")
|
||||
offsetStr := c.DefaultQuery("offset", "0")
|
||||
status := c.DefaultQuery("status", "active")
|
||||
status := c.DefaultQuery("status", models.ContractStatusActive)
|
||||
|
||||
// Convert limit and offset to int
|
||||
limit, err := strconv.Atoi(limitStr)
|
||||
|
||||
@@ -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