/
githubmirror
/
photoprism
Обзор
Документация
Войти
/
githubmirror
/
photoprism
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
internal/entity/query/places.go
40 строк
1001 B
Michael Mayer
Query: Add code comments for easier troubleshooting #5235
30 сен 2025, 22:46
30 сен 2025, 22:46
6d551c5
Код
Авторство
О чём код?
package query import ( "github.com/photoprism/photoprism/internal/entity" ) // Cell represents the minimal fields needed for a place cell lookup. type Cell struct { ID string PlaceID string } // Cells is a convenience slice for bulk cell operations. type Cells []Cell // CellIDs returns all known S2 cell ids as Cell slice. func CellIDs() (result Cells, err error) { tableName := entity.Cell{}.TableName() var count int64 if err = UnscopedDb().Table(tableName).Where("id <> 'zz'").Count(&count).Error; err != nil { return result, err } result = make(Cells, 0, count) err = UnscopedDb().Table(tableName).Select("id, place_id").Where("id <> 'zz'").Order("id").Scan(&result).Error return result, err } // PurgePlaces removes unused entries from the places table. func PurgePlaces() error { query := `DELETE FROM places WHERE id NOT IN (SELECT DISTINCT place_id FROM cells) AND id NOT IN (SELECT DISTINCT place_id FROM photos)` return Db().Exec(query).Error }