2019-12-11 07:37:39 +01:00
|
|
|
/*
|
|
|
|
This package contains PhotoPrism database queries.
|
|
|
|
|
|
|
|
Additional information can be found in our Developer Guide:
|
|
|
|
|
|
|
|
https://github.com/photoprism/photoprism/wiki
|
|
|
|
*/
|
2020-01-05 14:18:40 +01:00
|
|
|
package query
|
2019-12-11 07:37:39 +01:00
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/photoprism/photoprism/internal/event"
|
|
|
|
|
|
|
|
"github.com/jinzhu/gorm"
|
|
|
|
)
|
|
|
|
|
|
|
|
var log = event.Log
|
|
|
|
|
|
|
|
// About 1km ('good enough' for now)
|
|
|
|
const SearchRadius = 0.009
|
|
|
|
|
2020-03-28 15:29:17 +01:00
|
|
|
// Query searches given an originals path and a db instance.
|
|
|
|
type Query struct {
|
|
|
|
db *gorm.DB
|
2019-12-11 07:37:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// SearchCount is the total number of search hits.
|
|
|
|
type SearchCount struct {
|
|
|
|
Total int
|
|
|
|
}
|
|
|
|
|
2020-03-28 15:29:17 +01:00
|
|
|
// New returns a new Query type with a given path and db instance.
|
|
|
|
func New(db *gorm.DB) *Query {
|
|
|
|
q := &Query{
|
|
|
|
db: db,
|
2019-12-11 07:37:39 +01:00
|
|
|
}
|
|
|
|
|
2020-03-28 15:29:17 +01:00
|
|
|
return q
|
2019-12-11 07:37:39 +01:00
|
|
|
}
|