Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport shorten column names from next (878e35b) #3768

Merged
merged 1 commit into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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