Docs: Improve code comments in internal/entity/country.go and cell.go

Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
Michael Mayer 2025-10-02 16:19:24 +02:00
parent 0893e1ac80
commit 5dda30e7e9
2 changed files with 6 additions and 6 deletions

View file

@ -13,7 +13,7 @@ import (
var cellMutex = sync.Mutex{}
// Cell represents an S2 cell with metadata and reference to a place.
// Cell represents an S2 cell with reverse-geocoded metadata and a linked place.
type Cell struct {
ID string `gorm:"type:VARBINARY(42);primary_key;auto_increment:false;" json:"ID" yaml:"ID"`
CellName string `gorm:"type:VARCHAR(200);" json:"Name" yaml:"Name,omitempty"`

View file

@ -8,7 +8,7 @@ import (
"github.com/photoprism/photoprism/pkg/txt"
)
// altCountryNames defines mapping between different names for the same country
// altCountryNames captures alternate spellings mapped to canonical country names.
var altCountryNames = map[string]string{
"us": "United States",
"usa": "United States",
@ -21,7 +21,7 @@ var altCountryNames = map[string]string{
// Countries represents a list of countries.
type Countries []Country
// Country represents a country location, used for labeling photos.
// Country represents a country entry used for labeling photos and locations.
type Country struct {
ID string `gorm:"type:VARBINARY(2);primary_key" json:"ID" yaml:"ID"`
CountrySlug string `gorm:"type:VARBINARY(160);unique_index;" json:"Slug" yaml:"-"`
@ -38,19 +38,19 @@ func (Country) TableName() string {
return "countries"
}
// UnknownCountry is defined here to use it as a default
// UnknownCountry is the fallback entry used when no country code is known.
var UnknownCountry = Country{
ID: UnknownID,
CountryName: maps.CountryNames[UnknownID],
CountrySlug: UnknownID,
}
// CreateUnknownCountry is used to initialize the database with the default country
// CreateUnknownCountry ensures the fallback country exists in the database.
func CreateUnknownCountry() {
UnknownCountry = *FirstOrCreateCountry(&UnknownCountry)
}
// NewCountry creates a new country, with default country code if not provided
// NewCountry creates a new Country entity, normalizing name and slug.
func NewCountry(countryCode string, countryName string) *Country {
if countryCode == "" {
return &UnknownCountry