Skip to content

Commit

Permalink
stores: fix query
Browse files Browse the repository at this point in the history
  • Loading branch information
peterjan committed Sep 18, 2023
1 parent 3e200c8 commit 6a716ef
Showing 1 changed file with 1 addition and 13 deletions.
14 changes: 1 addition & 13 deletions stores/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -1076,22 +1076,10 @@ func fetchUsedContracts(tx *gorm.DB, usedContracts map[types.PublicKey]types.Fil
fcids = append(fcids, fileContractID(fcid))
}

// append the fcids with the renewed contracts
var archived []dbArchivedContract
if err := tx.Model(&dbArchivedContract{}).
Where("fcid IN (?)", fcids).
Find(&archived).
Error; err != nil {
return nil, err
}
for _, a := range archived {
fcids = append(fcids, fileContractID(a.RenewedTo))
}

// fetch all contracts
var contracts []dbContract
if err := tx.Model(&dbContract{}).
Where("fcid IN (?)", fcids).
Where("fcid IN (?) OR renewed_from IN (?)", fcids).
Preload("Host").
Find(&contracts).Error; err != nil {
return nil, err
Expand Down

0 comments on commit 6a716ef

Please sign in to comment.