Skip to content

Commit

Permalink
game changing optimization for FindAssetByContent
Browse files Browse the repository at this point in the history
  • Loading branch information
caffix committed Aug 14, 2024
1 parent 1c794b8 commit b5b1a92
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions repository/sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,9 @@ func (sql *sqlRepository) FindAssetByContent(assetData oam.Asset, since time.Tim
var assets []Asset
var result *gorm.DB
if since.IsZero() {
result = sql.db.Find(&assets, jsonQuery)
result = sql.db.Where("type = ?", asset.Type).Find(&assets, jsonQuery)
} else {
result = sql.db.Where("last_seen > ?", since).Find(&assets, jsonQuery)
result = sql.db.Where("type = ? AND last_seen > ?", asset.Type, since).Find(&assets, jsonQuery)
}
if result.Error != nil {
return []*types.Asset{}, result.Error
Expand Down Expand Up @@ -361,7 +361,7 @@ func (sql *sqlRepository) isDuplicateRelation(source *types.Asset, relation stri
_ = sql.relationSeen(out)
rel, err = sql.relationById(out.ID)
if err != nil {
log.Println("[ERROR] failed to when re-retrieving relation", err)
log.Println("[ERROR] failed when re-retrieving relation", err)
return nil, false
}
dup = true
Expand Down

0 comments on commit b5b1a92

Please sign in to comment.