Skip to content

Commit d4e7b38

Browse files
committed
Merge branch 'hotfix/3.0.3'
2 parents ff1a804 + dd57ac0 commit d4e7b38

10 files changed

Lines changed: 161 additions & 10 deletions

File tree

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
on:
2+
push:
3+
tags:
4+
- "*.*.*"
5+
6+
name: Create Github Release
7+
8+
permissions:
9+
contents: write
10+
11+
env:
12+
COMPOSE_USER: runner
13+
14+
jobs:
15+
create-release:
16+
runs-on: ubuntu-latest
17+
env:
18+
COMPOSER_ALLOW_SUPERUSER: 1
19+
APP_ENV: prod
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
24+
- name: Composer install
25+
run: |
26+
docker network create frontend
27+
docker compose run --rm --user=root -e APP_ENV=prod phpfpm composer install --no-dev --optimize-autoloader
28+
docker compose run --rm --user=root -e APP_ENV=prod phpfpm composer clear-cache
29+
30+
- name: Make assets dir
31+
run: |
32+
mkdir -p ../assets
33+
34+
- name: Create archive
35+
run: |
36+
sudo chown -R runner:runner ./
37+
tar --exclude='.git' -zcf ../assets/${{ github.event.repository.name }}-${{ github.ref_name }}.tar.gz ./
38+
39+
- name: Create checksum
40+
run: |
41+
cd ../assets
42+
sha256sum ${{ github.event.repository.name }}-${{ github.ref_name }}.tar.gz > ../assets/checksum.txt
43+
44+
- name: Create a release in GitHub and uploads assets
45+
run: gh release create ${{ github.ref_name }} --verify-tag --generate-notes ../assets/*.*
46+
env:
47+
GITHUB_TOKEN: ${{ github.TOKEN }}
48+
shell: bash

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ See [keep a changelog] for information about writing changes to this log.
88

99
## [Unreleased]
1010

11+
## [3.0.3] - 2025-07-29
12+
13+
* [PR-37](https://github.com/itk-dev/sysstatus/pull/37)
14+
5050: Optimize db structure and indexes, Add progressbar to import jobs
15+
1116
## [3.0.2] - 2025-06-25
1217

1318
* [PR-35](https://github.com/itk-dev/sysstatus/pull/35)
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace DoctrineMigrations;
6+
7+
use Doctrine\DBAL\Schema\Schema;
8+
use Doctrine\Migrations\AbstractMigration;
9+
10+
/**
11+
* Auto-generated Migration: Please modify to your needs!
12+
*/
13+
final class Version20250729142154 extends AbstractMigration
14+
{
15+
public function getDescription(): string
16+
{
17+
return '';
18+
}
19+
20+
public function up(Schema $schema): void
21+
{
22+
// this up() migration is auto-generated, please modify it to your needs
23+
$this->addSql(<<<'SQL'
24+
ALTER TABLE report CHANGE sys_status sys_status VARCHAR(255) DEFAULT NULL, CHANGE sys_owner_sub sys_owner_sub VARCHAR(255) DEFAULT NULL
25+
SQL);
26+
$this->addSql(<<<'SQL'
27+
CREATE INDEX archived_status_owner_idx ON report (archived_at, sys_status, sys_owner_sub)
28+
SQL);
29+
$this->addSql(<<<'SQL'
30+
CREATE INDEX sys_internal_id_idx ON report (sys_internal_id)
31+
SQL);
32+
$this->addSql(<<<'SQL'
33+
ALTER TABLE system CHANGE sys_owner_sub sys_owner_sub VARCHAR(255) DEFAULT NULL
34+
SQL);
35+
$this->addSql(<<<'SQL'
36+
CREATE INDEX archived_status_owner_idx ON system (archived_at, sys_status, sys_owner_sub)
37+
SQL);
38+
$this->addSql(<<<'SQL'
39+
CREATE INDEX sys_internal_id_idx ON system (sys_internal_id)
40+
SQL);
41+
}
42+
43+
public function down(Schema $schema): void
44+
{
45+
// this down() migration is auto-generated, please modify it to your needs
46+
$this->addSql(<<<'SQL'
47+
DROP INDEX archived_status_owner_idx ON system
48+
SQL);
49+
$this->addSql(<<<'SQL'
50+
DROP INDEX sys_internal_id_idx ON system
51+
SQL);
52+
$this->addSql(<<<'SQL'
53+
ALTER TABLE system CHANGE sys_owner_sub sys_owner_sub LONGTEXT DEFAULT NULL
54+
SQL);
55+
$this->addSql(<<<'SQL'
56+
DROP INDEX archived_status_owner_idx ON report
57+
SQL);
58+
$this->addSql(<<<'SQL'
59+
DROP INDEX sys_internal_id_idx ON report
60+
SQL);
61+
$this->addSql(<<<'SQL'
62+
ALTER TABLE report CHANGE sys_status sys_status LONGTEXT DEFAULT NULL, CHANGE sys_owner_sub sys_owner_sub LONGTEXT DEFAULT NULL
63+
SQL);
64+
}
65+
}

src/Command/AbstractImportCommand.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use App\Service\BaseImporter;
77
use Doctrine\ORM\EntityManagerInterface;
88
use Symfony\Component\Console\Command\Command;
9+
use Symfony\Component\Console\Helper\ProgressBar;
910
use Symfony\Component\Console\Output\OutputInterface;
1011

1112
abstract class AbstractImportCommand extends Command
@@ -22,13 +23,15 @@ public function __construct(
2223
*
2324
* @throws \Exception
2425
*/
25-
protected function import(string $type, string $src, OutputInterface $output): void
26+
protected function import(string $type, string $src, OutputInterface $output, bool $progress = false): void
2627
{
2728
$success = true;
2829
$errorMessage = null;
2930

31+
$progressBar = $progress ? new ProgressBar($output) : null;
32+
3033
try {
31-
$this->importer->import($src);
34+
$this->importer->import($src, $progressBar);
3235
} catch (\Exception $e) {
3336
$success = false;
3437
$errorMessage = $e->getMessage();

src/Command/ReportImportCommand.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Doctrine\ORM\EntityManagerInterface;
88
use Symfony\Component\Console\Input\InputArgument;
99
use Symfony\Component\Console\Input\InputInterface;
10+
use Symfony\Component\Console\Input\InputOption;
1011
use Symfony\Component\Console\Output\OutputInterface;
1112

1213
class ReportImportCommand extends AbstractImportCommand
@@ -22,6 +23,7 @@ protected function configure(): void
2223
->setName('itstyr:import:report')
2324
->setDescription('Import reports from feed.')
2425
->addArgument('src', InputArgument::REQUIRED, 'The src of the feed.')
26+
->addOption('progress', 'p', InputOption::VALUE_NONE, 'The src of the feed.')
2527
;
2628
}
2729

@@ -30,7 +32,7 @@ protected function configure(): void
3032
*/
3133
protected function execute(InputInterface $input, OutputInterface $output): int
3234
{
33-
$this->import(Report::class, $input->getArgument('src'), $output);
35+
$this->import(Report::class, $input->getArgument('src'), $output, $input->getOption('progress'));
3436

3537
return 0;
3638
}

src/Entity/Report.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
use Gedmo\Timestampable\Traits\TimestampableEntity;
1515

1616
#[ORM\Entity(repositoryClass: ReportRepository::class)]
17+
#[ORM\Index(columns: ['archived_at', 'sys_status', 'sys_owner_sub'], name: 'archived_status_owner_idx')]
18+
#[ORM\Index(columns: ['sys_internal_id'], name: 'sys_internal_id_idx')]
1719
#[Loggable]
1820
class Report implements \Stringable
1921
{
@@ -108,7 +110,7 @@ class Report implements \Stringable
108110
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
109111
private ?\DateTimeInterface $sysDateUse = null;
110112

111-
#[ORM\Column(type: Types::TEXT, nullable: true)]
113+
#[ORM\Column(type: Types::STRING, nullable: true)]
112114
private ?string $sysStatus = null;
113115

114116
#[ORM\Column(type: Types::TEXT, nullable: true)]
@@ -132,7 +134,7 @@ class Report implements \Stringable
132134
#[ORM\Column(type: Types::TEXT, nullable: true)]
133135
private ?string $sysVersion = null;
134136

135-
#[ORM\Column(type: Types::TEXT, nullable: true)]
137+
#[ORM\Column(type: Types::STRING, nullable: true)]
136138
private ?string $sysOwnerSub = null;
137139

138140
#[ORM\Column(type: Types::TEXT, nullable: true)]

src/Entity/System.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
use Gedmo\Timestampable\Traits\TimestampableEntity;
1515

1616
#[ORM\Entity(repositoryClass: SystemRepository::class)]
17+
#[ORM\Index(columns: ['archived_at', 'sys_status', 'sys_owner_sub'], name: 'archived_status_owner_idx')]
18+
#[ORM\Index(columns: ['sys_internal_id'], name: 'sys_internal_id_idx')]
1719
#[Loggable]
1820
class System implements \Stringable
1921
{
@@ -123,7 +125,7 @@ class System implements \Stringable
123125
#[ORM\Column(type: Types::TEXT, nullable: true)]
124126
private ?string $sysVersion = null;
125127

126-
#[ORM\Column(type: Types::TEXT, nullable: true)]
128+
#[ORM\Column(type: Types::STRING, nullable: true)]
127129
private ?string $sysOwnerSub = null;
128130

129131
#[ORM\Column(length: 255, nullable: true)]
@@ -132,7 +134,7 @@ class System implements \Stringable
132134
#[ORM\Column(nullable: true)]
133135
private ?int $sysInternalId = null;
134136

135-
#[ORM\Column(length: 255, nullable: true)]
137+
#[ORM\Column(type: Types::STRING, nullable: true)]
136138
private ?string $sysStatus = null;
137139

138140
#[ORM\Column(name: 'edoc_url', length: 255, nullable: true)]

src/Service/ImportInterface.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace App\Service;
44

5+
use Symfony\Component\Console\Helper\ProgressBar;
6+
57
interface ImportInterface
68
{
79
/**
@@ -10,5 +12,5 @@ interface ImportInterface
1012
* @param string $src
1113
* Path to the source
1214
*/
13-
public function import(string $src): void;
15+
public function import(string $src, ?ProgressBar $progressBar = null): void;
1416
}

src/Service/ReportImporter.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
namespace App\Service;
44

55
use App\Entity\Report;
6+
use Symfony\Component\Console\Helper\ProgressBar;
67

78
class ReportImporter extends BaseImporter
89
{
9-
public function import(string $src): void
10+
public function import(string $src, ?ProgressBar $progressBar = null): void
1011
{
1112
$systemURL = getenv('SYSTEM_URL');
1213

@@ -18,6 +19,8 @@ public function import(string $src): void
1819
return;
1920
}
2021

22+
$progressBar?->setMaxSteps(\count($entries));
23+
2124
// List of ids from Anmeldelsesportalen.
2225
$sysInternalIds = [];
2326

@@ -99,8 +102,12 @@ public function import(string $src): void
99102
$report->setSysOwnerSub($subGroupName);
100103
}
101104
}
105+
106+
$progressBar?->advance();
102107
}
103108

109+
$progressBar?->setMessage('Starting archiving ...');
110+
104111
// Archive reports that no longer exist in anmeldelsesportalen.
105112
$this->reportRepository->createQueryBuilder('e')
106113
->update()
@@ -112,6 +119,10 @@ public function import(string $src): void
112119
->execute()
113120
;
114121

122+
$progressBar?->setMessage('Flushing ...');
123+
115124
$this->entityManager->flush();
125+
126+
$progressBar?->finish();
116127
}
117128
}

src/Service/SystemImporter.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use App\Repository\SelfServiceAvailableFromItemRepository;
99
use App\Repository\SystemRepository;
1010
use Doctrine\ORM\EntityManagerInterface;
11+
use Symfony\Component\Console\Helper\ProgressBar;
1112

1213
class SystemImporter extends BaseImporter
1314
{
@@ -21,7 +22,7 @@ public function __construct(
2122
parent::__construct($reportRepository, $systemRepository, $groupRepository, $entityManager);
2223
}
2324

24-
public function import(string $src): void
25+
public function import(string $src, ?ProgressBar $progressBar = null): void
2526
{
2627
$systemURL = getenv('SYSTEM_URL');
2728

@@ -33,6 +34,8 @@ public function import(string $src): void
3334
return;
3435
}
3536

37+
$progressBar?->setMaxSteps(\count($entries));
38+
3639
// List of ids from Systemoversigten.
3740
$sysInternalIds = [];
3841

@@ -137,10 +140,14 @@ public function import(string $src): void
137140
$system->setSysOwnerSub($subGroupName);
138141
}
139142
}
143+
144+
$progressBar?->advance();
140145
}
141146

142147
// Archive systems that no longer exist in Systemoversigten.
143148

149+
$progressBar?->setMessage('Starting archiving ...');
150+
144151
$this->systemRepository->createQueryBuilder('e')
145152
->update()
146153
->set('e.archivedAt', ':now')
@@ -152,6 +159,10 @@ public function import(string $src): void
152159
->execute()
153160
;
154161

162+
$progressBar?->setMessage('Flushing ...');
163+
155164
$this->entityManager->flush();
165+
166+
$progressBar?->finish();
156167
}
157168
}

0 commit comments

Comments
 (0)