From 8f104655d3b155c0c30ad53ce953785f56b00612 Mon Sep 17 00:00:00 2001 From: caffix Date: Sat, 9 Nov 2024 21:52:21 +0000 Subject: [PATCH] additional fixes related to time --- repository/edge.go | 4 ++-- repository/entity.go | 6 +++--- repository/tag.go | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/repository/edge.go b/repository/edge.go index 08ad478..08c74c1 100644 --- a/repository/edge.go +++ b/repository/edge.go @@ -132,7 +132,7 @@ func (sql *sqlRepository) IncomingEdges(entity *types.Entity, since time.Time, l if since.IsZero() { result = sql.db.Where("to_entity_id = ?", entityId).Find(&edges) } else { - result = sql.db.Where("to_entity_id = ? AND last_seen >= ?", entityId, since).Find(&edges) + result = sql.db.Where("to_entity_id = ? AND last_seen >= ?", entityId, since.UTC()).Find(&edges) } if err := result.Error; err != nil { return nil, err @@ -173,7 +173,7 @@ func (sql *sqlRepository) OutgoingEdges(entity *types.Entity, since time.Time, l if since.IsZero() { result = sql.db.Where("from_entity_id = ?", entityId).Find(&edges) } else { - result = sql.db.Where("from_entity_id = ? AND last_seen >= ?", entityId, since).Find(&edges) + result = sql.db.Where("from_entity_id = ? AND last_seen >= ?", entityId, since.UTC()).Find(&edges) } if err := result.Error; err != nil { return nil, err diff --git a/repository/entity.go b/repository/entity.go index f45d583..bce6b90 100644 --- a/repository/entity.go +++ b/repository/entity.go @@ -183,7 +183,7 @@ func (sql *sqlRepository) FindEntityByContent(assetData oam.Asset, since time.Ti if since.IsZero() { result = sql.db.Where("etype = ?", entity.Type).Find(&entities, jsonQuery) } else { - result = sql.db.Where("etype = ? AND last_seen >= ?", entity.Type, since).Find(&entities, jsonQuery) + result = sql.db.Where("etype = ? AND last_seen >= ?", entity.Type, since.UTC()).Find(&entities, jsonQuery) } if result.Error != nil { return []*types.Entity{}, result.Error @@ -222,7 +222,7 @@ func (sql *sqlRepository) FindEntityById(id string, since time.Time) (*types.Ent if since.IsZero() { result = sql.db.First(&entity) } else { - result = sql.db.Where("last_seen >= ?", since).First(&entity) + result = sql.db.Where("last_seen >= ?", since.UTC()).First(&entity) } if result.Error != nil { return nil, result.Error @@ -252,7 +252,7 @@ func (sql *sqlRepository) FindEntitiesByType(atype oam.AssetType, since time.Tim if since.IsZero() { result = sql.db.Where("etype = ?", atype).Find(&entities) } else { - result = sql.db.Where("etype = ? AND last_seen >= ?", atype, since).Find(&entities) + result = sql.db.Where("etype = ? AND last_seen >= ?", atype, since.UTC()).Find(&entities) } if result.Error != nil { return []*types.Entity{}, result.Error diff --git a/repository/tag.go b/repository/tag.go index ed36136..9320cdb 100644 --- a/repository/tag.go +++ b/repository/tag.go @@ -80,7 +80,7 @@ func (sql *sqlRepository) FindEntityTagById(id string, since time.Time) (*types. if since.IsZero() { result = sql.db.First(&tag) } else { - result = sql.db.Where("last_seen >= ?", since).First(&tag) + result = sql.db.Where("last_seen >= ?", since.UTC()).First(&tag) } if result.Error != nil { return nil, result.Error @@ -113,7 +113,7 @@ func (sql *sqlRepository) GetEntityTags(entity *types.Entity, since time.Time, n if since.IsZero() { result = sql.db.Where("entity_id = ?", entityId).Find(&tags) } else { - result = sql.db.Where("entity_id = ? AND last_seen >= ?", entityId, since).Find(&tags) + result = sql.db.Where("entity_id = ? AND last_seen >= ?", entityId, since.UTC()).Find(&tags) } if err := result.Error; err != nil { return nil, err @@ -236,7 +236,7 @@ func (sql *sqlRepository) FindEdgeTagById(id string, since time.Time) (*types.Ed if since.IsZero() { result = sql.db.First(&tag) } else { - result = sql.db.Where("last_seen >= ?", since).First(&tag) + result = sql.db.Where("last_seen >= ?", since.UTC()).First(&tag) } if result.Error != nil { return nil, result.Error @@ -266,7 +266,7 @@ func (sql *sqlRepository) GetEdgeTags(edge *types.Edge, since time.Time, names . if since.IsZero() { result = sql.db.Where("edge_id = ?", edgeId).Find(&tags) } else { - result = sql.db.Where("edge_id = ? AND last_seen >= ?", edgeId, since).Find(&tags) + result = sql.db.Where("edge_id = ? AND last_seen >= ?", edgeId, since.UTC()).Find(&tags) } if err := result.Error; err != nil { return nil, err