fix(location-events): adding location id to the database from agent call
This commit is contained in:
@ -88,7 +88,7 @@ const eventTools = `
|
|||||||
},
|
},
|
||||||
"startDateTime": {
|
"startDateTime": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "The event's start date and time in ISO 8601 format (e.g., '2025-04-18T10:00:00Z' or '2025-04-18T11:00:00+01:00'). Include if available."
|
"description": "The event's start date and time in ISO 8601 format (e.g., '2025-04-18T10:00:00Z'). Include if available."
|
||||||
},
|
},
|
||||||
"endDateTime": {
|
"endDateTime": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
@ -96,7 +96,7 @@ const eventTools = `
|
|||||||
},
|
},
|
||||||
"locationId": {
|
"locationId": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "The unique identifier (UUID or similar) for the event's location. Only include this if a location was specified for the event AND its ID was successfully retrieved using the getEventLocationId tool."
|
"description": "The unique identifier (UUID or similar) for the event's location. Use this if available, do not invent it."
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": ["name"]
|
"required": ["name"]
|
||||||
@ -140,6 +140,7 @@ type createEventArguments struct {
|
|||||||
StartDateTime *string `json:"startDateTime"`
|
StartDateTime *string `json:"startDateTime"`
|
||||||
EndDateTime *string `json:"endDateTime"`
|
EndDateTime *string `json:"endDateTime"`
|
||||||
OrganizerName *string `json:"organizerName"`
|
OrganizerName *string `json:"organizerName"`
|
||||||
|
LocationID *string `json:"locationId"`
|
||||||
}
|
}
|
||||||
type linkEventArguments struct {
|
type linkEventArguments struct {
|
||||||
EventID string `json:"eventId"`
|
EventID string `json:"eventId"`
|
||||||
@ -182,10 +183,16 @@ func NewEventAgent(log *log.Logger, eventsModel models.EventModel, locationModel
|
|||||||
return model.Events{}, err
|
return model.Events{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
locationId, err := uuid.Parse(*args.LocationID)
|
||||||
|
if err != nil {
|
||||||
|
return model.Events{}, err
|
||||||
|
}
|
||||||
|
|
||||||
events, err := eventsModel.Save(ctx, info.UserId, model.Events{
|
events, err := eventsModel.Save(ctx, info.UserId, model.Events{
|
||||||
Name: args.Name,
|
Name: args.Name,
|
||||||
StartDateTime: &startTime,
|
StartDateTime: &startTime,
|
||||||
EndDateTime: &endTime,
|
EndDateTime: &endTime,
|
||||||
|
LocationID: &locationId,
|
||||||
})
|
})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -31,8 +31,8 @@ func (m EventModel) List(ctx context.Context, userId uuid.UUID) ([]model.Events,
|
|||||||
func (m EventModel) Save(ctx context.Context, userId uuid.UUID, event model.Events) (model.Events, error) {
|
func (m EventModel) Save(ctx context.Context, userId uuid.UUID, event model.Events) (model.Events, error) {
|
||||||
// TODO tx here
|
// TODO tx here
|
||||||
insertEventStmt := Events.
|
insertEventStmt := Events.
|
||||||
INSERT(Events.Name, Events.Description, Events.StartDateTime, Events.EndDateTime).
|
INSERT(Events.Name, Events.Description, Events.StartDateTime, Events.EndDateTime, Events.LocationID).
|
||||||
VALUES(event.Name, event.Description, event.StartDateTime, event.EndDateTime).
|
VALUES(event.Name, event.Description, event.StartDateTime, event.EndDateTime, event.LocationID).
|
||||||
RETURNING(Events.AllColumns)
|
RETURNING(Events.AllColumns)
|
||||||
|
|
||||||
insertedEvent := model.Events{}
|
insertedEvent := model.Events{}
|
||||||
|
Reference in New Issue
Block a user