Skip to content

Commit

Permalink
Fixes SQL error in GetClipsQualifyingForRemoval
Browse files Browse the repository at this point in the history
This commit: 16c0961 did some cleanup
of the GetClipsQualifyingForRemoval and removed a small hack used to
get the main select with the n.<name of column>. Causing the unit
tests to fail. Adds back the AS statement the correct way, utilizing
the built in features of gorm.
  • Loading branch information
isZumpo committed Apr 22, 2024
1 parent cb99a02 commit 9904eba
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion internal/datastore/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ func (ds *DataStore) GetClipsQualifyingForRemoval(minHours int, minClips int) ([
}

// Main query to find clips qualifying for removal based on retention policy
err := ds.DB.Model(&Note{}).
err := ds.DB.Table("(?) AS n", ds.DB.Model(&Note{})).
Select("n.ID, n.scientific_name, n.clip_name, sub.num_recordings").
Joins("INNER JOIN (?) AS sub ON n.ID = sub.ID", subquery).
Where("strftime('%s', 'now') - strftime('%s', begin_time) > ?", minHours*3600). // Convert hours to seconds for comparison
Expand Down

0 comments on commit 9904eba

Please sign in to comment.