From 3a2141aab5b4025568eb761bbba13b141b2b6b8a Mon Sep 17 00:00:00 2001
From: pb <pierre.bayle@irt-stexupery.com>
Date: Wed, 28 May 2025 16:22:26 +0200
Subject: [PATCH] adding log to measure search time

---
 models/booking/booking.go | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/models/booking/booking.go b/models/booking/booking.go
index 4d6b20a..1c1fac0 100644
--- a/models/booking/booking.go
+++ b/models/booking/booking.go
@@ -4,6 +4,7 @@ import (
 	"time"
 
 	"cloud.o-forge.io/core/oc-lib/dbs"
+	"cloud.o-forge.io/core/oc-lib/logs"
 	"cloud.o-forge.io/core/oc-lib/models/common/enum"
 	"cloud.o-forge.io/core/oc-lib/models/utils"
 	"cloud.o-forge.io/core/oc-lib/tools"
@@ -39,6 +40,8 @@ func (wfa *Booking) Check(id string, start time.Time, end *time.Time, parrallelA
 		end = &e
 	}
 	accessor := NewAccessor(nil)
+	l := logs.GetLogger().With().Str("Search Check", "Booking").Logger()
+	l.Debug().Msg("Starting to search")
 	res, code, err := accessor.Search(&dbs.Filters{
 		And: map[string][]dbs.Filter{ // check if there is a booking on the same compute resource by filtering on the compute_resource_id, the state and the execution date
 			"resource_id": {{Operator: dbs.EQUAL.String(), Value: id}},
@@ -49,6 +52,9 @@ func (wfa *Booking) Check(id string, start time.Time, end *time.Time, parrallelA
 			},
 		},
 	}, "", wfa.IsDraft)
+
+	l.Debug().Msg("Search finished")
+
 	if code != 200 {
 		return false, err
 	}