Skip to content

Commit

Permalink
Merge pull request #3768 from nextcloud/backport/fix/878e35b
Browse files Browse the repository at this point in the history
Backport shorten column names from next (878e35b)
  • Loading branch information
dartcafe authored Nov 6, 2024
2 parents f61c5bb + d878d9d commit b939f2e
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()
*/

class Poll extends EntityWithUser implements JsonSerializable {
Expand Down Expand Up @@ -157,9 +157,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;

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

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

$this->urlGenerator = Container::queryClass(IURLGenerator::class);
$this->userSession = Container::queryClass(UserSession::class);
Expand Down Expand Up @@ -251,9 +251,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 @@ -528,7 +528,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');

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

0 comments on commit b939f2e

Please sign in to comment.