Skip to content

Commit

Permalink
shorten column names
Browse files Browse the repository at this point in the history
Signed-off-by: dartcafe <[email protected]>
  • Loading branch information
dartcafe committed Oct 7, 2024
1 parent 552cd76 commit 878e35b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
26 changes: 13 additions & 13 deletions lib/Db/Poll.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@
* @method int getCountOptions()
*
* Magic functions for subqueried columns
* @method int getCurrentUserCountOrphanedVotes()
* @method int getCurrentUserCountVotes()
* @method int getCurrentUserCountVotesYes()
* @method int getCurrentUserOrphanedVotes()
* @method int getCurrentUserVotes()
* @method int getCurrentUserVotesYes()
* @method int getParticipantsCount()
*/

Expand Down Expand Up @@ -158,9 +158,9 @@ class Poll extends EntityWithUser implements JsonSerializable {
protected int $countOptions = 0;

// subqueried columns
protected int $currentUserCountOrphanedVotes = 0;
protected int $currentUserCountVotes = 0;
protected int $currentUserCountVotesYes = 0;
protected int $currentUserOrphanedVotes = 0;
protected int $currentUserVotes = 0;
protected int $currentUserVotesYes = 0;
protected int $participantsCount = 0;

public function __construct() {
Expand All @@ -185,9 +185,9 @@ public function __construct() {
$this->addType('countOptions', 'int');

// subqueried columns
$this->addType('currentUserCountVotes', 'int');
$this->addType('currentUserCountVotesYes', 'int');
$this->addType('currentUserCountOrphanedVotes', 'int');
$this->addType('currentUserVotes', 'int');
$this->addType('currentUserVotesYes', 'int');
$this->addType('currentUserOrphanedVotes', 'int');
$this->addType('participantsCount', 'int');

$this->urlGenerator = Container::queryClass(IURLGenerator::class);
Expand Down Expand Up @@ -254,9 +254,9 @@ public function getCurrentUserStatus(): array {
'isNoUser' => !$this->userSession->getIsLoggedIn(),
'isOwner' => $this->getIsPollOwner(),
'userId' => $this->getUserId(),
'orphanedVotes' => $this->getCurrentUserCountOrphanedVotes(),
'yesVotes' => $this->getCurrentUserCountVotesYes(),
'countVotes' => $this->getCurrentUserCountVotes(),
'orphanedVotes' => $this->getCurrentUserOrphanedVotes(),
'yesVotes' => $this->getCurrentUserVotesYes(),
'countVotes' => $this->getCurrentUserVotes(),
'shareToken' => $this->getShareToken(),
'groupInvitations' => $this->getGroupShares(),
];
Expand Down Expand Up @@ -531,7 +531,7 @@ private function getIsOpenPoll(): bool {
* @return bool Returns true, if the current user is already a particitipant of the current poll.
*/
private function getIsParticipant(): bool {
return $this->getCurrentUserCountVotes() > 0;
return $this->getCurrentUserVotes() > 0;
}

/**
Expand Down
6 changes: 3 additions & 3 deletions lib/Db/PollMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,9 @@ protected function buildQuery(): IQueryBuilder {
$paramUser = $qb->createNamedParameter($currentUserId, IQueryBuilder::PARAM_STR);
$paramAnswerYes = $qb->createNamedParameter(Vote::VOTE_YES, IQueryBuilder::PARAM_STR);

$qb->selectAlias($qb->createFunction('(' . $this->subQueryVotesCount(self::TABLE, $paramUser)->getSQL() . ')'), 'current_user_count_votes');
$qb->selectAlias($qb->createFunction('(' . $this->subQueryVotesCount(self::TABLE, $paramUser, $paramAnswerYes)->getSQL() . ')'), 'current_user_count_votes_yes');
$qb->selectAlias($qb->createFunction('(' . $this->subQueryOrphanedVotesCount(self::TABLE, $paramUser)->getSQL() . ')'), 'current_user_count_orphaned_votes');
$qb->selectAlias($qb->createFunction('(' . $this->subQueryVotesCount(self::TABLE, $paramUser)->getSQL() . ')'), 'current_user_votes');
$qb->selectAlias($qb->createFunction('(' . $this->subQueryVotesCount(self::TABLE, $paramUser, $paramAnswerYes)->getSQL() . ')'), 'current_user_votes_yes');
$qb->selectAlias($qb->createFunction('(' . $this->subQueryOrphanedVotesCount(self::TABLE, $paramUser)->getSQL() . ')'), 'current_user_orphaned_votes');
$qb->selectAlias($qb->createFunction('(' . $this->subQueryParticipantsCount(self::TABLE)->getSQL() . ')'), 'participants_count');

$this->joinOptionsForMaxDate($qb, self::TABLE);
Expand Down

0 comments on commit 878e35b

Please sign in to comment.