From 6503008cc042ee61c1e39a72b212d4c4c5343d74 Mon Sep 17 00:00:00 2001 From: Michael Mayer Date: Tue, 21 Sep 2021 12:11:51 +0200 Subject: [PATCH] People: Prepare for release #22 (#1541) --- internal/commands/reset.go | 2 +- internal/config/db.go | 2 +- internal/entity/deprecated.go | 3 +++ internal/entity/entity.go | 13 ++++++++----- internal/entity/face.go | 4 ++-- internal/entity/marker.go | 12 ++++++------ internal/entity/subject.go | 12 ++++++------ internal/face/thresholds.go | 2 +- 8 files changed, 28 insertions(+), 22 deletions(-) diff --git a/internal/commands/reset.go b/internal/commands/reset.go index 665a86624..852a67609 100644 --- a/internal/commands/reset.go +++ b/internal/commands/reset.go @@ -49,7 +49,7 @@ func resetAction(ctx *cli.Context) error { tables.Drop() log.Infoln("restoring default schema") - entity.MigrateDb() + entity.MigrateDb(true) if conf.AdminPassword() != "" { log.Infoln("restoring initial admin password") diff --git a/internal/config/db.go b/internal/config/db.go index 51786f3ba..3f801dc93 100644 --- a/internal/config/db.go +++ b/internal/config/db.go @@ -236,7 +236,7 @@ func (c *Config) SetDbOptions() { func (c *Config) InitDb() { c.SetDbOptions() entity.SetDbProvider(c) - entity.MigrateDb() + entity.MigrateDb(c.Experimental()) entity.Admin.InitPassword(c.AdminPassword()) diff --git a/internal/entity/deprecated.go b/internal/entity/deprecated.go index 43fff7516..6c71b4330 100644 --- a/internal/entity/deprecated.go +++ b/internal/entity/deprecated.go @@ -23,6 +23,7 @@ var DeprecatedTables = Deprecated{ "subjects_dev7", "subjects_dev8", "subjects_dev9", + "subjects_dev10", "markers_dev1", "markers_dev2", "markers_dev3", @@ -32,6 +33,7 @@ var DeprecatedTables = Deprecated{ "markers_dev7", "markers_dev8", "markers_dev9", + "markers_dev10", "faces_dev1", "faces_dev2", "faces_dev3", @@ -41,4 +43,5 @@ var DeprecatedTables = Deprecated{ "faces_dev7", "faces_dev8", "faces_dev9", + "faces_dev10", } diff --git a/internal/entity/entity.go b/internal/entity/entity.go index 6d4e14349..5f85d03d6 100644 --- a/internal/entity/entity.go +++ b/internal/entity/entity.go @@ -122,7 +122,7 @@ func (list Types) Drop() { } } -// CreateDefaultFixtures creates default database entries for test and production. +// CreateDefaultFixtures inserts default fixtures for test and production. func CreateDefaultFixtures() { CreateUnknownAddress() CreateDefaultUsers() @@ -133,16 +133,19 @@ func CreateDefaultFixtures() { CreateUnknownLens() } -// MigrateDb creates all tables and inserts default entities as needed. -func MigrateDb() { - DeprecatedTables.Drop() +// MigrateDb creates database tables and inserts default fixtures as needed. +func MigrateDb(dropDeprecated bool) { + if dropDeprecated { + DeprecatedTables.Drop() + } + Entities.Migrate() Entities.WaitForMigration() CreateDefaultFixtures() } -// ResetTestFixtures drops database tables for all known entities and re-creates them with fixtures. +// ResetTestFixtures re-creates registered database tables and inserts test fixtures. func ResetTestFixtures() { Entities.Migrate() Entities.WaitForMigration() diff --git a/internal/entity/face.go b/internal/entity/face.go index a1a26e96c..cc5dad33d 100644 --- a/internal/entity/face.go +++ b/internal/entity/face.go @@ -23,7 +23,7 @@ type Face struct { ID string `gorm:"type:VARBINARY(42);primary_key;auto_increment:false;" json:"ID" yaml:"ID"` FaceSrc string `gorm:"type:VARBINARY(8);" json:"Src" yaml:"Src,omitempty"` FaceHidden bool `json:"Hidden" yaml:"Hidden,omitempty"` - SubjUID string `gorm:"type:VARBINARY(42);index;" json:"SubjUID" yaml:"SubjUID,omitempty"` + SubjUID string `gorm:"type:VARBINARY(42);index;default:'';" json:"SubjUID" yaml:"SubjUID,omitempty"` Samples int `json:"Samples" yaml:"Samples,omitempty"` SampleRadius float64 `json:"SampleRadius" yaml:"SampleRadius,omitempty"` Collisions int `json:"Collisions" yaml:"Collisions,omitempty"` @@ -40,7 +40,7 @@ var Faceless = []string{""} // TableName returns the entity database table name. func (Face) TableName() string { - return "faces_dev10" + return "faces" } // NewFace returns a new face. diff --git a/internal/entity/marker.go b/internal/entity/marker.go index 8a911f66a..9d6227844 100644 --- a/internal/entity/marker.go +++ b/internal/entity/marker.go @@ -26,7 +26,7 @@ const ( // Marker represents an image marker point. type Marker struct { MarkerUID string `gorm:"type:VARBINARY(42);primary_key;auto_increment:false;" json:"UID" yaml:"UID"` - FileUID string `gorm:"type:VARBINARY(42);index;" json:"FileUID" yaml:"FileUID"` + FileUID string `gorm:"type:VARBINARY(42);index;default:'';" json:"FileUID" yaml:"FileUID"` MarkerType string `gorm:"type:VARBINARY(8);default:'';" json:"Type" yaml:"Type"` MarkerSrc string `gorm:"type:VARBINARY(8);default:'';" json:"Src" yaml:"Src,omitempty"` MarkerName string `gorm:"type:VARCHAR(255);" json:"Name" yaml:"Name,omitempty"` @@ -36,7 +36,7 @@ type Marker struct { SubjSrc string `gorm:"type:VARBINARY(8);index:idx_markers_subj_uid_src;default:'';" json:"SubjSrc" yaml:"SubjSrc,omitempty"` subject *Subject `gorm:"foreignkey:SubjUID;association_foreignkey:SubjUID;association_autoupdate:false;association_autocreate:false;association_save_reference:false"` FaceID string `gorm:"type:VARBINARY(42);index;" json:"FaceID" yaml:"FaceID,omitempty"` - FaceDist float64 `gorm:"default:-1" json:"FaceDist" yaml:"FaceDist,omitempty"` + FaceDist float64 `gorm:"default:-1;" json:"FaceDist" yaml:"FaceDist,omitempty"` face *Face `gorm:"foreignkey:FaceID;association_foreignkey:ID;association_autoupdate:false;association_autocreate:false;association_save_reference:false"` EmbeddingsJSON json.RawMessage `gorm:"type:MEDIUMBLOB;" json:"-" yaml:"EmbeddingsJSON,omitempty"` embeddings Embeddings `gorm:"-"` @@ -46,9 +46,9 @@ type Marker struct { W float32 `gorm:"type:FLOAT;" json:"W" yaml:"W,omitempty"` H float32 `gorm:"type:FLOAT;" json:"H" yaml:"H,omitempty"` Q int `json:"Q" yaml:"Q,omitempty"` - Size int `gorm:"default:-1" json:"Size" yaml:"Size,omitempty"` - Score int `gorm:"type:SMALLINT" json:"Score" yaml:"Score,omitempty"` - Thumb string `gorm:"type:VARBINARY(128);index" json:"Thumb" yaml:"Thumb,omitempty"` + Size int `gorm:"default:-1;" json:"Size" yaml:"Size,omitempty"` + Score int `gorm:"type:SMALLINT;" json:"Score" yaml:"Score,omitempty"` + Thumb string `gorm:"type:VARBINARY(128);index;default:'';" json:"Thumb" yaml:"Thumb,omitempty"` MatchedAt *time.Time `sql:"index" json:"MatchedAt" yaml:"MatchedAt,omitempty"` CreatedAt time.Time UpdatedAt time.Time @@ -56,7 +56,7 @@ type Marker struct { // TableName returns the entity database table name. func (Marker) TableName() string { - return "markers_dev10" + return "markers" } // BeforeCreate creates a random UID if needed before inserting a new row to the database. diff --git a/internal/entity/subject.go b/internal/entity/subject.go index 06166270a..8fa06a327 100644 --- a/internal/entity/subject.go +++ b/internal/entity/subject.go @@ -21,11 +21,11 @@ type Subjects []Subject // Subject represents a named photo subject, typically a person. type Subject struct { SubjUID string `gorm:"type:VARBINARY(42);primary_key;auto_increment:false;" json:"UID" yaml:"UID"` - SubjType string `gorm:"type:VARBINARY(8);default:''" json:"Type,omitempty" yaml:"Type,omitempty"` - SubjSrc string `gorm:"type:VARBINARY(8);default:''" json:"Src,omitempty" yaml:"Src,omitempty"` - SubjSlug string `gorm:"type:VARBINARY(255);index;default:''" json:"Slug" yaml:"-"` - SubjName string `gorm:"type:VARCHAR(255);unique_index;default:''" json:"Name" yaml:"Name"` - SubjAlias string `gorm:"type:VARCHAR(255);default:''" json:"Alias" yaml:"Alias"` + SubjType string `gorm:"type:VARBINARY(8);default:'';" json:"Type,omitempty" yaml:"Type,omitempty"` + SubjSrc string `gorm:"type:VARBINARY(8);default:'';" json:"Src,omitempty" yaml:"Src,omitempty"` + SubjSlug string `gorm:"type:VARBINARY(255);index;default:'';" json:"Slug" yaml:"-"` + SubjName string `gorm:"type:VARCHAR(255);unique_index;default:'';" json:"Name" yaml:"Name"` + SubjAlias string `gorm:"type:VARCHAR(255);default:'';" json:"Alias" yaml:"Alias"` SubjBio string `gorm:"type:TEXT;" json:"Bio" yaml:"Bio,omitempty"` SubjNotes string `gorm:"type:TEXT;" json:"Notes,omitempty" yaml:"Notes,omitempty"` SubjFavorite bool `gorm:"default:false" json:"Favorite" yaml:"Favorite,omitempty"` @@ -42,7 +42,7 @@ type Subject struct { // TableName returns the entity database table name. func (Subject) TableName() string { - return "subjects_dev10" + return "subjects" } // BeforeCreate creates a random UID if needed before inserting a new row to the database. diff --git a/internal/face/thresholds.go b/internal/face/thresholds.go index 4adf3c583..cb7e3aa1b 100644 --- a/internal/face/thresholds.go +++ b/internal/face/thresholds.go @@ -8,7 +8,7 @@ var CropSize = crop.Sizes[crop.Tile160] var ClusterCore = 4 var ClusterMinScore = 15 var ClusterMinSize = 95 -var ClusterRadius = 0.58 +var ClusterRadius = 0.69 var MatchRadius = 0.46 var SampleThreshold = 2 * ClusterCore var OverlapThreshold = 42