[ENTITY][ActorTag] Add 'canonical' field to actor_tag

This commit is contained in:
Hugo Sales 2021-11-28 11:14:58 +00:00 committed by Diogo Peralta Cordeiro
parent 798a5f3796
commit f986f59424
Signed by: diogo
GPG Key ID: 18D2D35001FBFAB0
3 changed files with 27 additions and 10 deletions

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types = 1);
// {{{ License
// This file is part of GNU social - https://www.gnu.org/software/social
//
@ -19,9 +21,9 @@
namespace App\Entity;
use App\Core\Cache;
use App\Core\DB\DB;
use App\Core\Entity;
use Component\Tag\Tag;
use DateTimeInterface;
/**
@ -45,7 +47,8 @@ class ActorTag extends Entity
private int $tagger;
private int $tagged;
private string $tag;
private \DateTimeInterface $modified;
private string $canonical;
private DateTimeInterface $modified;
public function setTagger(int $tagger): self
{
@ -80,6 +83,17 @@ class ActorTag extends Entity
return $this->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;
@ -101,7 +115,8 @@ class ActorTag extends Entity
'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'],
'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'],

View File

@ -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()),
);
}

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types = 1);
// {{{ License/
// This file is part of GNU social - https://www.gnu.org/software/social
//
@ -44,7 +46,7 @@ class NoteTag extends Entity
private string $tag;
private string $canonical;
private int $note_id;
private \DateTimeInterface $created;
private DateTimeInterface $created;
public function setTag(string $tag): self
{
@ -100,7 +102,7 @@ class NoteTag extends Entity
'description' => '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'],
],