Fix Duration Compare in photos estimate
Remove the conversion to hours which provides incorrect duration comapre result
This commit is contained in:
parent
6e144fe13a
commit
189fae6daf
2 changed files with 16 additions and 1 deletions
|
@ -64,7 +64,7 @@ func (m *Photo) EstimateLocation(force bool) {
|
|||
return
|
||||
} else if force || m.EstimatedAt == nil {
|
||||
// Proceed.
|
||||
} else if hours := TimeStamp().Sub(*m.EstimatedAt) / time.Hour; hours < MetadataEstimateInterval {
|
||||
} else if hours := TimeStamp().Sub(*m.EstimatedAt); hours < MetadataEstimateInterval {
|
||||
// Ignore if location has been estimated recently (in the last 7 days by default).
|
||||
return
|
||||
}
|
||||
|
|
|
@ -75,6 +75,21 @@ func TestPhoto_EstimateLocation(t *testing.T) {
|
|||
assert.Equal(t, UnknownCountry.CountryName, m2.CountryName())
|
||||
assert.Equal(t, SrcAuto, m2.PlaceSrc)
|
||||
})
|
||||
t.Run("NotRecentlyEstimated", func(t *testing.T) {
|
||||
estimateTime := TimeStamp().Add(-1 * (MetadataEstimateInterval + 2*time.Hour))
|
||||
m2 := Photo{
|
||||
CameraID: 2,
|
||||
TakenSrc: SrcMeta,
|
||||
PhotoName: "PhotoWithoutLocation",
|
||||
OriginalName: "demo/xyy.jpg",
|
||||
EstimatedAt: &estimateTime,
|
||||
TakenAt: time.Date(2016, 11, 11, 8, 7, 18, 0, time.UTC)}
|
||||
assert.Equal(t, UnknownID, m2.CountryCode())
|
||||
m2.EstimateLocation(false)
|
||||
assert.Equal(t, "mx", m2.CountryCode())
|
||||
assert.Equal(t, "Mexico", m2.CountryName())
|
||||
assert.Equal(t, SrcEstimate, m2.PlaceSrc)
|
||||
})
|
||||
t.Run("ForceEstimate", func(t *testing.T) {
|
||||
m2 := Photo{
|
||||
CameraID: 2,
|
||||
|
|
Loading…
Add table
Reference in a new issue