From a67eaa395c6882490d08e0c364b9ff79aa51e4bc Mon Sep 17 00:00:00 2001 From: Nicholas Cristofaro Date: Tue, 11 Feb 2025 21:17:00 -0300 Subject: [PATCH] store: Rename vector store parameters --- internal/store/gorm/vector.go | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/internal/store/gorm/vector.go b/internal/store/gorm/vector.go index 3a1a4ec..11bda85 100644 --- a/internal/store/gorm/vector.go +++ b/internal/store/gorm/vector.go @@ -9,8 +9,12 @@ import ( type vectorModel struct { gorm.Model - ParetoD uint - Pareto paretoModel `gorm:"foreignKey:ParetoID"` + ParetoID uint + Pareto paretoModel `gorm:"foreignKey:ParetoID"` + + Elements []float64 + Objectives []float64 + CrowdingDistance float64 } type vectorStore struct{ *gorm.DB } @@ -18,27 +22,32 @@ type vectorStore struct{ *gorm.DB } func newVectorStore(db *gorm.DB) *vectorStore { return &vectorStore{db} } func (st *vectorStore) CreateVector( - ctx context.Context, usr *api.Vector, + ctx context.Context, vec *api.Vector, paretoID uint, ) error { - vector := vectorModel{} - st.DB.WithContext(ctx).Create(&vector) - return nil + vector := vectorModel{ + ParetoID: paretoID, + Elements: vec.Elements, + Objectives: vec.Objectives, + CrowdingDistance: vec.CrowdingDistance, + } + tx := st.DB.WithContext(ctx).Create(&vector) + return tx.Error } func (st *vectorStore) GetVector( - ctx context.Context, usrIDs *api.VectorIDs, + ctx context.Context, vecIDs *api.VectorIDs, ) (*api.Vector, error) { return nil, nil } func (st *vectorStore) UpdateVector( - ctx context.Context, usr *api.Vector, fields ...string, + ctx context.Context, vec *api.Vector, fields ...string, ) error { return nil } func (st *vectorStore) DeleteVector( - ctx context.Context, usrIDs *api.VectorIDs, + ctx context.Context, vecIDs *api.VectorIDs, ) error { return nil }