Skip to content

Commit

Permalink
Dirty hack: INGYO/NYC abstentions
Browse files Browse the repository at this point in the history
  • Loading branch information
CatoTH committed Nov 24, 2024
1 parent 3d345ba commit 1f4c54e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
19 changes: 17 additions & 2 deletions models/db/VotingBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use app\components\UrlHelper;
use app\models\exceptions\Internal;
use app\models\majorityType\IMajorityType;
use app\plugins\european_youth_forum\VotingHelper;
use app\models\policies\{IPolicy, LoggedIn};
use app\models\quorumType\{IQuorumType, NoQuorum};
use app\models\settings\{AntragsgruenApp, VotingBlock as VotingBlockSettings};
Expand Down Expand Up @@ -661,13 +662,15 @@ public function getVotingItemBlocks(bool $includeUngrouped, ?IMotion $adhocFilte
}

/**
* @return array{votes: int, users: int, abstentions: int}
* @return array{votes: int, users: int, abstentions: int, abstentions_ingyo: int, abstentions_nyc: int}
*/
public function getVoteStatistics(): array
{
$total = 0;
$voteUserIds = [];
$abstainedUserIds = [];
$abstainedUserIdsNyc = [];
$abstainedUserIdsIngyo = [];

$groupsMyMotionIds = [];
$groupsMyAmendmentIds = [];
Expand All @@ -694,6 +697,12 @@ public function getVoteStatistics(): array
foreach ($this->votes as $vote) {
if ($vote->questionId !== null && $vote->questionId === $abstentionId) {
$abstainedUserIds[] = $vote->userId;
if ($vote->getUser() && VotingHelper::userIsNyc($this->consultation, $vote->getUser())) {

Check failure on line 700 in models/db/VotingBlock.php

View workflow job for this annotation

GitHub Actions / evaluate-pr

Call to static method userIsNyc() on an unknown class app\plugins\european_youth_forum\VotingHelper.
$abstainedUserIdsNyc[] = $vote->userId;
}
if ($vote->getUser() && VotingHelper::userIsIngyo($this->consultation, $vote->getUser())) {

Check failure on line 703 in models/db/VotingBlock.php

View workflow job for this annotation

GitHub Actions / evaluate-pr

Call to static method userIsIngyo() on an unknown class app\plugins\european_youth_forum\VotingHelper.
$abstainedUserIdsIngyo[] = $vote->userId;
}
if ($vote->userId && !in_array($vote->userId, $voteUserIds)) {
$voteUserIds[] = $vote->userId;
}
Expand Down Expand Up @@ -724,7 +733,13 @@ public function getVoteStatistics(): array
}
}

return ['votes' => $total, 'users' => count($voteUserIds), 'abstentions' => count($abstainedUserIds)];
return [
'votes' => $total,
'users' => count($voteUserIds),
'abstentions' => count($abstainedUserIds),
'abstentions_nyc' => count($abstainedUserIdsNyc),
'abstentions_ingyo' => count($abstainedUserIdsIngyo),
];
}

/**
Expand Down
2 changes: 2 additions & 0 deletions models/proposedProcedure/AgendaVoting.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ private function getApiObject(?string $title, ?User $user, string $context): arr
$votingBlockJson['votes_total'] = $stats['votes'];
$votingBlockJson['votes_users'] = $stats['users'];
$votingBlockJson['abstentions_total'] = $stats['abstentions'];
$votingBlockJson['abstentions_nyc'] = $stats['abstentions_nyc'];
$votingBlockJson['abstentions_ingyo'] = $stats['abstentions_ingyo'];
$votingBlockJson['vote_policy'] = $this->voting->getVotingPolicy()->getApiObject();

$quorumType = $this->voting->getQuorumType();
Expand Down
8 changes: 6 additions & 2 deletions views/voting/admin-votings.vue.php
Original file line number Diff line number Diff line change
Expand Up @@ -680,11 +680,15 @@ class="glyphicon glyphicon-new-window" aria-label="<?= Html::encode(Yii::t('voti
}
},
abstentionsStr: function () {
let str = '';
if (this.voting.abstentions_total === 1) {
return abstentions1;
str = abstentions1;
} else {
return abstentionsx.replace(/%NUM%/, this.voting.abstentions_total);
str = abstentionsx.replace(/%NUM%/, this.voting.abstentions_total);
}
str += " (" + this.voting.abstentions_nyc + " NYC / " + this.voting.abstentions_ingyo + " INGYO)";

return str;
}
},
methods: {
Expand Down

0 comments on commit 1f4c54e

Please sign in to comment.