Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove findLatestNonStableVersion
Browse files Browse the repository at this point in the history
karniv00l committed Sep 1, 2020

Verified

This commit was signed with the committer’s verified signature.
tzarc Nick Brassel
1 parent b0f3cd8 commit fa55f78
Showing 4 changed files with 2 additions and 43 deletions.
2 changes: 1 addition & 1 deletion src/Command/ClearOldPrivateDistsCommand.php
Original file line number Diff line number Diff line change
@@ -46,7 +46,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$package->name(),
$version->version(),
'zip',
$this->query->findLatestNonStableVersion($version->version())->reference(),
$version->reference(),
);
}
}
9 changes: 1 addition & 8 deletions src/Query/User/Model/Version.php
Original file line number Diff line number Diff line change
@@ -6,26 +6,19 @@

final class Version
{
private string $id;
private string $version;
private string $reference;
private int $size;
private \DateTimeImmutable $date;

public function __construct(string $id, string $version, string $reference, int $size, \DateTimeImmutable $date)
public function __construct(string $version, string $reference, int $size, \DateTimeImmutable $date)
{
$this->id = $id;
$this->version = $version;
$this->reference = $reference;
$this->size = $size;
$this->date = $date;
}

public function id(): string
{
return $this->id;
}

public function version(): string
{
return $this->version;
2 changes: 0 additions & 2 deletions src/Query/User/PackageQuery.php
Original file line number Diff line number Diff line change
@@ -68,6 +68,4 @@ public function getAllSynchronizedCount(): int;
* @return Version[]
*/
public function findNonStableVersions(string $packageId): array;

public function findLatestNonStableVersion(string $version): Version;
}
32 changes: 0 additions & 32 deletions src/Query/User/PackageQuery/DbalPackageQuery.php
Original file line number Diff line number Diff line change
@@ -125,7 +125,6 @@ public function getVersions(string $packageId, int $limit = 20, int $offset = 0)
{
return array_map(function (array $data): Version {
return new Version(
$data['id'],
$data['version'],
$data['reference'],
$data['size'],
@@ -297,7 +296,6 @@ public function findNonStableVersions(string $packageId): array
{
return array_map(function (array $data): Version {
return new Version(
$data['id'],
$data['version'],
$data['reference'],
0,
@@ -317,34 +315,4 @@ public function findNonStableVersions(string $packageId): array
]
));
}

public function findLatestNonStableVersion(string $version): Version
{
$data = $this->connection->fetchAssoc(
'SELECT
id,
version,
reference
FROM organization_package_version
WHERE version = :version AND stability != :stability
ORDER BY date DESC
LIMIT 1',
[
':version' => $version,
':stability' => VersionEntity::STABILITY_STABLE,
]
);

if ($data === false) {
throw new \InvalidArgumentException("Version {$version} not found");
}

return new Version(
$data['id'],
$data['version'],
$data['reference'],
0,
new \DateTimeImmutable()
);
}
}

0 comments on commit fa55f78

Please sign in to comment.