From f986f594240b79c493986dd3654589ceefa4a6af Mon Sep 17 00:00:00 2001 From: Hugo Sales Date: Sun, 28 Nov 2021 11:14:58 +0000 Subject: [PATCH] [ENTITY][ActorTag] Add 'canonical' field to actor_tag --- src/Entity/ActorTag.php | 27 +++++++++++++++++++++------ src/Entity/Language.php | 4 ++-- src/Entity/NoteTag.php | 6 ++++-- 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/src/Entity/ActorTag.php b/src/Entity/ActorTag.php index d2c0a557e5..1e467fbe4a 100644 --- a/src/Entity/ActorTag.php +++ b/src/Entity/ActorTag.php @@ -1,5 +1,7 @@ tag; } + public function setCanonical(string $canonical): self + { + $this->canonical = $canonical; + return $this; + } + + public function getCanonical(): string + { + return $this->canonical; + } + public function setModified(DateTimeInterface $modified): self { $this->modified = $modified; @@ -99,10 +113,11 @@ class ActorTag extends Entity return [ 'name' => 'actor_tag', 'fields' => [ - 'tagger' => ['type' => 'int', 'foreign key' => true, 'target' => 'Actor.id', 'multiplicity' => 'one to one', 'name' => 'actor_tag_tagger_fkey', 'not null' => true, 'description' => 'actor making the tag'], - 'tagged' => ['type' => 'int', 'foreign key' => true, 'target' => 'Actor.id', 'multiplicity' => 'one to one', 'name' => 'actor_tag_tagged_fkey', 'not null' => true, 'description' => 'actor tagged'], - 'tag' => ['type' => 'varchar', 'length' => 64, 'not null' => true, 'description' => 'hash tag associated with this notice'], - 'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'], + 'tagger' => ['type' => 'int', 'foreign key' => true, 'target' => 'Actor.id', 'multiplicity' => 'one to one', 'name' => 'actor_tag_tagger_fkey', 'not null' => true, 'description' => 'actor making the tag'], + 'tagged' => ['type' => 'int', 'foreign key' => true, 'target' => 'Actor.id', 'multiplicity' => 'one to one', 'name' => 'actor_tag_tagged_fkey', 'not null' => true, 'description' => 'actor tagged'], + 'tag' => ['type' => 'varchar', 'length' => Tag::MAX_TAG_LENGTH, 'not null' => true, 'description' => 'hash tag associated with this actor'], + 'canonical' => ['type' => 'varchar', 'length' => Tag::MAX_TAG_LENGTH, 'not null' => true, 'description' => 'ascii slug of tag'], + 'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'], ], 'primary key' => ['tagger', 'tagged', 'tag'], 'indexes' => [ diff --git a/src/Entity/Language.php b/src/Entity/Language.php index 1129e79fa5..288ed24118 100644 --- a/src/Entity/Language.php +++ b/src/Entity/Language.php @@ -111,8 +111,8 @@ class Language extends Entity public static function getFromId(int $id): self { return Cache::getHashMapKey( - 'languages-id', - (string) $id, + map_key: 'languages-id', + key: (string) $id, calculate_map: fn () => F\reindex(DB::dql('select l from language l'), fn (self $l) => (string) $l->getId()), ); } diff --git a/src/Entity/NoteTag.php b/src/Entity/NoteTag.php index 7834ceb31a..c4fe4e02ea 100644 --- a/src/Entity/NoteTag.php +++ b/src/Entity/NoteTag.php @@ -1,5 +1,7 @@ 'Hash tags on notes', 'fields' => [ 'tag' => ['type' => 'varchar', 'length' => Tag::MAX_TAG_LENGTH, 'not null' => true, 'description' => 'hash tag associated with this note'], - 'canonical' => ['type' => 'varchar', 'length' => Tag::MAX_TAG_LENGTH, 'not null' => true, 'description' => 'ascii slug of hash tag'], + 'canonical' => ['type' => 'varchar', 'length' => Tag::MAX_TAG_LENGTH, 'not null' => true, 'description' => 'ascii slug of tag'], 'note_id' => ['type' => 'int', 'foreign key' => true, 'target' => 'Note.id', 'multiplicity' => 'one to one', 'not null' => true, 'description' => 'foreign key to tagged note'], 'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'], ],