• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

bvlion / AppTanServer / 20205654148

14 Dec 2025 09:04AM UTC coverage: 25.627%. First build
20205654148

push

github

bvlion
format

12 of 49 new or added lines in 18 files covered. (24.49%)

143 of 558 relevant lines covered (25.63%)

0.8 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Infrastructure/Persistence/ProcessingRequest/PdoProcessingRequestRepository.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace App\Infrastructure\Persistence\ProcessingRequest;
6

7
use App\Domain\ProcessingRequest\ProcessingRequest;
8
use App\Domain\ProcessingRequest\ProcessingRequestRepository;
9
use App\Domain\ProcessingRequest\ProcessingStatus;
10
use PDO;
11

12
class PdoProcessingRequestRepository implements ProcessingRequestRepository
13
{
14
  public function __construct(private PDO $pdo)
15
  {
NEW
16
  }
×
17

18
  public function findFailed(): array
19
  {
20
    $stmt = $this->pdo->prepare("
×
21
      SELECT package_name, app_name, status, updated_at
22
      FROM processing_requests
23
      WHERE status = 'failed'
24
      ORDER BY updated_at ASC
25
    ");
×
26
    $stmt->execute();
×
27

28
    $results = [];
×
29
    while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
×
30
      $results[] = new ProcessingRequest(
×
31
        packageName: $row['package_name'],
×
32
        appName: $row['app_name'],
×
33
        status: ProcessingStatus::fromString($row['status']),
×
34
        updatedAt: new \DateTime($row['updated_at'])
×
35
      );
×
36
    }
37

38
    return $results;
×
39
  }
40

41
  public function insertIfNotExists(string $packageName, string $appName): void
42
  {
43
    $stmt = $this->pdo->prepare("
×
44
      INSERT IGNORE INTO processing_requests (package_name, app_name, status)
45
      VALUES (:package, :app, 'waiting')
46
    ");
×
47
    $stmt->execute([
×
48
      'package' => $packageName,
×
49
      'app'   => $appName,
×
50
    ]);
×
51
  }
52

53
  public function lockAndMarkInProgress(string $packageName, string $appName): bool
54
  {
55
    $this->pdo->beginTransaction();
×
56

57
    // Lock対象を取得(存在しない可能性は insertIfNotExists で排除済みとする)
58
    $stmt = $this->pdo->prepare("
×
59
      SELECT status FROM processing_requests
60
      WHERE package_name = :package AND app_name = :app
61
      FOR UPDATE
62
    ");
×
63
    $stmt->execute([
×
64
      'package' => $packageName,
×
65
      'app'   => $appName,
×
66
    ]);
×
67

68
    $row = $stmt->fetch(PDO::FETCH_ASSOC);
×
69

70
    if (!$row || !in_array($row['status'], ['waiting', 'failed'], true)) {
×
71
      $this->pdo->rollBack();
×
72
      return false;
×
73
    }
74

75
      // ステータスを in_progress に更新
76
    $stmt = $this->pdo->prepare("
×
77
      UPDATE processing_requests
78
      SET status = 'in_progress', updated_at = NOW()
79
      WHERE package_name = :package AND app_name = :app
80
    ");
×
81
    $stmt->execute([
×
82
      'package' => $packageName,
×
83
      'app'   => $appName,
×
84
    ]);
×
85

86
    $this->pdo->commit();
×
87
    return true;
×
88
  }
89

90
  public function updateStatus(
91
    string $packageName,
92
    string $appName,
93
    ProcessingStatus $status
94
  ): void {
95
    $stmt = $this->pdo->prepare("
×
96
      UPDATE processing_requests
97
      SET status = :status, updated_at = NOW()
98
      WHERE package_name = :package AND app_name = :app
99
    ");
×
100
    $stmt->execute([
×
101
      'status' => $status->value,
×
102
      'package' => $packageName,
×
103
      'app' => $appName,
×
104
    ]);
×
105
  }
106
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc