Skip to content

Commit

Permalink
GH-446 review
Browse files Browse the repository at this point in the history
  • Loading branch information
rinkp authored Dec 18, 2024
1 parent f9acc81 commit 5cd0bc4
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 27 deletions.
1 change: 0 additions & 1 deletion module/Database/migrations/Version20241124183711.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public function up(Schema $schema): void
public function down(Schema $schema): void
{
// phpcs:disable SlevomatCodingStandard.Functions.RequireMultiLineCall.RequiredMultiLineCall
$this->addSql('CREATE SCHEMA public');
$this->addSql('CREATE SEQUENCE installationfunction_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE TABLE installationfunction (id INT NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
// phpcs:enable SlevomatCodingStandard.Functions.RequireMultiLineCall.RequiredMultiLineCall
Expand Down
23 changes: 23 additions & 0 deletions module/Database/src/Mapper/ProspectiveMember.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,29 @@ public function findWithFullyExpiredOrFailedCheckout(): array
return $qb->getQuery()->getResult();
}

/**
* Find all prospective members wihout any checkout session (should not happen)
*
* @return ProspectiveMemberModel[]
*/
public function findWithoutCheckout(): array
{
// Get all checkout sessions
$checkoutSessions = $this->em->createQueryBuilder();
$checkoutSessions->select('pmwithcs.lidnr')
->from(CheckoutSessionModel::class, 'cs')
->innerJoin('cs.prospectiveMember', 'pmwithcs');

Check failure on line 193 in module/Database/src/Mapper/ProspectiveMember.php

View workflow job for this annotation

GitHub Actions / php-codesniffer / PHP_CodeSniffer (8.3)

Whitespace found at end of line
// Get all prospective members without a checkout session that are there for more than 30 days
$qb = $this->getRepository()->createQueryBuilder('m');
$qb->where($qb->expr()->notIn('m.lidnr', $checkoutSessions->getDQL()))
->andWhere('m.changedOn <= :fullyExpired');

$qb->setParameter('fullyExpired', (new DateTime())->sub(new DateInterval('P31D')));

return $qb->getQuery()->getResult();
}

/**
* Persist a member model.
*/
Expand Down
7 changes: 5 additions & 2 deletions module/Database/src/Model/Meeting.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Database\Model;

use Application\Model\Enums\AppLanguages;
use Application\Model\Enums\MeetingTypes;
use Database\Model\SubDecision\Minutes;
use DateTime;
Expand Down Expand Up @@ -194,11 +195,13 @@ public function toArray(): array
*/
public function getNumberAsOrdinal(?string $locale): string
{

Check failure on line 197 in module/Database/src/Model/Meeting.php

View workflow job for this annotation

GitHub Actions / php-codesniffer / PHP_CodeSniffer (8.3)

Expected 0 blank lines after opening function brace; 2 found

Check failure on line 198 in module/Database/src/Model/Meeting.php

View workflow job for this annotation

GitHub Actions / php-codesniffer / PHP_CodeSniffer (8.3)

Functions must not contain multiple empty lines in a row; found 2 empty lines

if (null === $locale) {
$locale = 'nl_NL';
$locale = AppLanguages::Dutch->getLocale();
}

if ('en_GB' === $locale) {
if (AppLanguages::English->getLocale() === $locale) {
return (new NumberFormatter($locale, NumberFormatter::ORDINAL))->format($this->getNumber());
}

Expand Down
10 changes: 0 additions & 10 deletions module/Database/src/Model/SubDecision.php
Original file line number Diff line number Diff line change
Expand Up @@ -265,16 +265,6 @@ protected function replaceContentPlaceholders(
return str_replace(array_keys($replacements), $replacements, $template);
}

/**
* Get the statutory content of the subdecision
*/
// final public function getContent(): string
// {
// $translator = new DummyTranslator();

// return $this->getTranslatedContent($translator, AppLanguages::Dutch);
// }

/**
* Get the content in the current language (requires real translator)
*/
Expand Down
7 changes: 5 additions & 2 deletions module/Database/src/Service/Member.php
Original file line number Diff line number Diff line change
Expand Up @@ -629,11 +629,14 @@ public function removeProspective(ProspectiveMemberModel $member): void

/**
* Remove all prospective members whose last Checkout Session has fully expired (1 + 30 + 1 day ago) or failed 31
* days ago.
* days ago or who don't have a checkout session.
*/
public function removeExpiredProspectiveMembers(): void
{
$prospectiveMembers = $this->getProspectiveMemberMapper()->findWithFullyExpiredOrFailedCheckout();
$prospectiveMembers = array_merge(

Check failure on line 636 in module/Database/src/Service/Member.php

View workflow job for this annotation

GitHub Actions / php-codesniffer / PHP_CodeSniffer (8.3)

Function array_merge() should not be referenced via a fallback global name, but via a use statement.
$this->getProspectiveMemberMapper()->findWithFullyExpiredOrFailedCheckout(),
$this->getProspectiveMemberMapper()->findWithoutCheckout(),
);

foreach ($prospectiveMembers as $prospectiveMember) {
$this->removeProspective($prospectiveMember);
Expand Down
7 changes: 4 additions & 3 deletions module/Database/view/database/meeting/decisionform.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use Database\Model\Meeting;
use Laminas\View\Renderer\PhpRenderer;

/** @var PhpRenderer|HelperTrait $this */
$translator = $this->plugin('translate')->getTranslator();
?>
<?php if (isset($form)): ?>
<?php
Expand Down Expand Up @@ -79,15 +80,15 @@ case 'other':
?>
<h1><?= $this->translate('Decision') ?> <?= $decision->getHash() ?> <?= $this->translate('reads as follows:') ?></h1>
<?php foreach ($decision->getSubdecisions() as $subdecision): ?>
<?= $this->escapeHtml($subdecision->getContent($this->plugin('translate')->getTranslator())) ?>
<?= $this->escapeHtml($subdecision->getContent($translator)) ?>
<?php endforeach; ?>

<br>
<span class="hidden" id="decision-contents">
<?= sprintf(
'\decision[%s]{%s}',
$this->escapeHtml($decision->getTranslatedContent($this->plugin('translate')->getTranslator(), AppLanguages::English, true)),
$this->escapeHtml($decision->getTranslatedContent($this->plugin('translate')->getTranslator(), AppLanguages::Dutch, true)),
$this->escapeHtml($decision->getTranslatedContent($translator, AppLanguages::English, true)),
$this->escapeHtml($decision->getTranslatedContent($translator, AppLanguages::Dutch, true)),
) ?>
</span>

Expand Down
8 changes: 4 additions & 4 deletions module/Database/view/database/meeting/view.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use Laminas\View\Renderer\PhpRenderer;
* @var PhpRenderer|HelperTrait $this
* @var MeetingModel $meeting
*/

$translator = $this->plugin('translate')->getTranslator();
// determine last decision of each point
$map = array();
foreach ($meeting->getDecisions() as $decision) {
Expand Down Expand Up @@ -98,14 +98,14 @@ $(document).ready(function () {
</button>
<ul>
<?php foreach ($decision->getSubdecisions() as $subdecision): ?>
<li><?= $this->escapeHtml($subdecision->getContent($this->plugin('translate')->getTranslator())) ?></li>
<li><?= $this->escapeHtml($subdecision->getContent($translator)) ?></li>
<?php endforeach; ?>
</ul>
<span class="hidden" id="<?= $decision->getHash() ?>">
<?= sprintf(
'\decision[%s]{%s}',
$this->escapeHtmlAttr($decision->getTranslatedContent($this->plugin('translate')->getTranslator(), AppLanguages::English, true)),
$this->escapeHtmlAttr($decision->getTranslatedContent($this->plugin('translate')->getTranslator(), AppLanguages::Dutch, true)),
$this->escapeHtmlAttr($decision->getTranslatedContent($translator, AppLanguages::English, true)),
$this->escapeHtmlAttr($decision->getTranslatedContent($translator, AppLanguages::Dutch, true)),
) ?>
</span>
</li>
Expand Down
9 changes: 4 additions & 5 deletions module/Report/migrations/Version20241124183712.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,16 @@ public function getDescription(): string
public function up(Schema $schema): void
{
// phpcs:disable SlevomatCodingStandard.Functions.RequireMultiLineCall.RequiredMultiLineCall
$this->addSql('ALTER TABLE decision ADD contentEN TEXT NOT NULL');
$this->addSql('ALTER TABLE decision RENAME COLUMN content TO contentNL');
$this->addSql('ALTER TABLE subdecision ADD contentEN TEXT NOT NULL');
$this->addSql('ALTER TABLE subdecision RENAME COLUMN content TO contentNL');
$this->addSql('ALTER TABLE Decision ADD contentEN TEXT NOT NULL');
$this->addSql('ALTER TABLE Decision RENAME COLUMN content TO contentNL');
$this->addSql('ALTER TABLE SubDecision ADD contentEN TEXT NOT NULL');
$this->addSql('ALTER TABLE SubDecision RENAME COLUMN content TO contentNL');
// phpcs:enable SlevomatCodingStandard.Functions.RequireMultiLineCall.RequiredMultiLineCall
}

public function down(Schema $schema): void
{
// phpcs:disable SlevomatCodingStandard.Functions.RequireMultiLineCall.RequiredMultiLineCall
$this->addSql('CREATE SCHEMA public');
$this->addSql('ALTER TABLE Decision ADD content TEXT NOT NULL');
$this->addSql('ALTER TABLE Decision DROP contentNL');
$this->addSql('ALTER TABLE Decision DROP contentEN');
Expand Down

0 comments on commit 5cd0bc4

Please sign in to comment.