[Actor] Refactor GSActor into Actor

This commit is contained in:
2021-09-18 03:22:27 +01:00
parent 6c899b7b61
commit 941cbe6599
73 changed files with 489 additions and 484 deletions

View File

@@ -41,7 +41,7 @@ class Poll extends Entity
// @codeCoverageIgnoreStart
private int $id;
private ?string $uri;
private ?int $gsactor_id;
private ?int $actor_id;
private int $note_id;
private ?string $question;
private ?string $options;
@@ -70,15 +70,15 @@ class Poll extends Entity
return $this->uri;
}
public function setGSActorId(?int $gsactor_id): self
public function setActorId(?int $actor_id): self
{
$this->gsactor_id = $gsactor_id;
$this->actor_id = $actor_id;
return $this;
}
public function getGSActorId(): ?int
public function getActorId(): ?int
{
return $this->gsactor_id;
return $this->actor_id;
}
public function setNoteId(int $note_id): self
@@ -150,14 +150,14 @@ class Poll extends Entity
'name' => 'poll',
'description' => 'Per-notice poll data for Poll plugin',
'fields' => [
'id' => ['type' => 'serial', 'not null' => true],
'uri' => ['type' => 'varchar', 'length' => 191],
'gsactor_id' => ['type' => 'int'],
'note_id' => ['type' => 'int', 'not null' => true],
'question' => ['type' => 'text'],
'options' => ['type' => 'text'],
'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'],
'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'],
'id' => ['type' => 'serial', 'not null' => true],
'uri' => ['type' => 'varchar', 'length' => 191],
'actor_id' => ['type' => 'int'],
'note_id' => ['type' => 'int', 'not null' => true],
'question' => ['type' => 'text'],
'options' => ['type' => 'text'],
'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'],
'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'],
],
'primary key' => ['id'],
'unique keys' => [

View File

@@ -42,7 +42,7 @@ class PollResponse extends Entity
private int $id;
private ?string $uri;
private int $poll_id;
private ?int $gsactor_id;
private ?int $actor_id;
private ?int $selection;
private \DateTimeInterface $created;
private \DateTimeInterface $modified;
@@ -80,15 +80,15 @@ class PollResponse extends Entity
return $this->poll_id;
}
public function setGSActorId(?int $gsactor_id): self
public function setActorId(?int $actor_id): self
{
$this->gsactor_id = $gsactor_id;
$this->actor_id = $actor_id;
return $this;
}
public function getGSActorId(): ?int
public function getActorId(): ?int
{
return $this->gsactor_id;
return $this->actor_id;
}
public function setSelection(?int $selection): self
@@ -140,25 +140,25 @@ class PollResponse extends Entity
'fields' => [
'id' => ['type' => 'serial', 'not null' => true],
//'uri' => array('type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'UUID to the response notice'),
'uri' => ['type' => 'varchar', 'length' => 191, 'description' => 'UUID to the response notice'],
'poll_id' => ['type' => 'int', 'length' => 36, 'not null' => true, 'description' => 'UUID of poll being responded to'],
'gsactor_id' => ['type' => 'int'],
'selection' => ['type' => 'int'],
'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'],
'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'],
'uri' => ['type' => 'varchar', 'length' => 191, 'description' => 'UUID to the response notice'],
'poll_id' => ['type' => 'int', 'length' => 36, 'not null' => true, 'description' => 'UUID of poll being responded to'],
'actor_id' => ['type' => 'int'],
'selection' => ['type' => 'int'],
'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'],
'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'],
],
'primary key' => ['id'],
'unique keys' => [
//'poll_uri_key' => array('uri'),
//'poll_response_poll_id_gsactor_id_key' => ['poll_id', 'gsactor_id'], //doctrine bug?
//'poll_response_poll_id_actor_id_key' => ['poll_id', 'actor_id'], //doctrine bug?
],
'foreign keys' => [
'foreign_poll' => ['poll', ['poll_id' => 'id']],
],
'indexes' => [
'poll_response_gsactor_id_poll_id_index' => ['gsactor_id', 'poll_id'],
'poll_response_actor_id_poll_id_index' => ['actor_id', 'poll_id'],
],
];
}
@@ -167,15 +167,15 @@ class PollResponse extends Entity
* Checks if a user already responded to the poll
*
* @param int $pollId
* @param int $gsactorId user
* @param int $actorId user
*
* @return bool
*/
public static function exits(int $pollId, int $gsactorId): bool
public static function exits(int $pollId, int $actorId): bool
{
$res = DB::dql('select pr from App\Entity\PollResponse pr
where pr.poll_id = :pollId and pr.gsactor_id = :gsactorId',
['pollId' => $pollId, 'gsactorId' => $gsactorId]);
where pr.poll_id = :pollId and pr.actor_id = :actorId',
['pollId' => $pollId, 'actorId' => $actorId]);
return count($res) != 0;
}
}