Added temperature exceded event
This commit is contained in:
@@ -12,18 +12,18 @@ import (
|
||||
)
|
||||
|
||||
|
||||
func GetNotificationsForUserID(userID int, afterTime time.Time) ([]models.GetNotificationsResponse, int, error) {
|
||||
func GetNotificationsForCompanyID(companyID int, afterTime time.Time) ([]models.GetNotificationsResponse, int, error) {
|
||||
// Create a slice to hold the notifications
|
||||
var notifications []models.Notification
|
||||
var customNotifications []models.GetNotificationsResponse
|
||||
|
||||
// Fetch notifications from the database based on UserID and creation time
|
||||
if err := shared.GetDb().Where("user_id = ? AND created_at > ?", userID, afterTime).Find(¬ifications).Error; err != nil {
|
||||
if err := shared.GetDb().Where("company_id = ? AND created_at > ?", companyID, afterTime).Find(¬ifications).Error; err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
log.Printf("GetNotificationsForUserID Error: No notifications found: %v", err)
|
||||
log.Printf("GetNotificationsForCompanyID Error: No notifications found: %v", err)
|
||||
return customNotifications, http.StatusNotFound, err
|
||||
} else {
|
||||
log.Printf("GetNotificationsForUserID Error: Database error: %v", err)
|
||||
log.Printf("GetNotificationsForCompanyID Error: Database error: %v", err)
|
||||
return customNotifications, http.StatusInternalServerError, err
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user