2021-11-12 05:09:17 +01:00
|
|
|
package query
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/photoprism/photoprism/internal/entity"
|
|
|
|
)
|
|
|
|
|
2021-11-18 00:46:34 +01:00
|
|
|
type Cell struct {
|
|
|
|
ID string
|
|
|
|
PlaceID string
|
|
|
|
}
|
|
|
|
|
|
|
|
type Cells []Cell
|
|
|
|
|
|
|
|
// CellIDs returns all known S2 cell ids as Cell slice.
|
|
|
|
func CellIDs() (result Cells, err error) {
|
2021-11-12 05:09:17 +01:00
|
|
|
tableName := entity.Cell{}.TableName()
|
|
|
|
|
|
|
|
var count int64
|
|
|
|
|
|
|
|
if err = UnscopedDb().Table(tableName).Where("id <> 'zz'").Count(&count).Error; err != nil {
|
2021-11-18 00:46:34 +01:00
|
|
|
return result, err
|
2021-11-12 05:09:17 +01:00
|
|
|
}
|
|
|
|
|
2021-11-18 00:46:34 +01:00
|
|
|
result = make(Cells, 0, count)
|
2021-11-12 05:09:17 +01:00
|
|
|
|
2021-11-18 00:46:34 +01:00
|
|
|
err = UnscopedDb().Table(tableName).Select("id, place_id").Where("id <> 'zz'").Order("id").Scan(&result).Error
|
2021-11-12 05:09:17 +01:00
|
|
|
|
2021-11-18 00:46:34 +01:00
|
|
|
return result, err
|
2021-11-12 05:09:17 +01:00
|
|
|
}
|