Skip to content

Commit

Permalink
Migrate CoverageSummaryDiff model to Eloquent
Browse files Browse the repository at this point in the history
  • Loading branch information
williamjallen committed Aug 15, 2023
1 parent 1e0e62b commit fc705da
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 120 deletions.
28 changes: 28 additions & 0 deletions app/Models/CoverageSummaryDiff.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;

/**
* @property int $buildid
* @property int $loctested
* @property int $locuntested
*
* @mixin Builder<CoverageSummaryDiff>
*/
class CoverageSummaryDiff extends Model
{
protected $table = 'coveragesummarydiff';

public $timestamps = false;

protected $primaryKey = 'buildid';

protected $fillable = [
'buildid',
'loctested',
'locuntested',
];
}
17 changes: 9 additions & 8 deletions app/cdash/app/Model/CoverageSummary.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
=========================================================================*/
namespace CDash\Model;

use App\Models\CoverageSummaryDiff;
use CDash\Database;
use Illuminate\Support\Facades\DB;

Expand Down Expand Up @@ -326,17 +327,17 @@ public function ComputeDifference($previous_parentid=null): bool
$previousloctested = intval($previouscoverage['loctested']);
$previouslocuntested = intval($previouscoverage['locuntested']);

$summaryDiff = new CoverageSummaryDiff();
$summaryDiff->BuildId = $this->BuildId;
$loctesteddiff = $loctested - $previousloctested;
$locuntesteddiff = $locuntested - $previouslocuntested;

// Don't log if no diff unless an entry already exists
// for this build.
if ($summaryDiff->Exists() || $loctesteddiff !== 0 || $locuntesteddiff !== 0) {
$summaryDiff->LocTested = $loctesteddiff;
$summaryDiff->LocUntested = $locuntesteddiff;
$summaryDiff->Insert();
// Don't log if no diff unless an entry already exists for this build.
if (CoverageSummaryDiff::where(['buildid' => $this->BuildId])->exists() || $loctesteddiff !== 0 || $locuntesteddiff !== 0) {
CoverageSummaryDiff::updateOrCreate([
'buildid' => $this->BuildId,
], [
'loctested' => $loctesteddiff,
'locuntested' => $locuntesteddiff,
]);
}
}

Expand Down
68 changes: 0 additions & 68 deletions app/cdash/app/Model/CoverageSummaryDiff.php

This file was deleted.

49 changes: 5 additions & 44 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -6950,6 +6950,11 @@ parameters:
count: 11
path: app/cdash/app/Model/CoverageSummary.php

-
message: "#^Dynamic call to static method Illuminate\\\\Database\\\\Eloquent\\\\Builder\\<App\\\\Models\\\\CoverageSummaryDiff\\>\\:\\:exists\\(\\)\\.$#"
count: 1
path: app/cdash/app/Model/CoverageSummary.php

-
message: "#^Method CDash\\\\Model\\\\CoverageSummary\\:\\:AddCoverage\\(\\) has parameter \\$coverage with no type specified\\.$#"
count: 1
Expand Down Expand Up @@ -7035,50 +7040,6 @@ parameters:
count: 1
path: app/cdash/app/Model/CoverageSummary.php

-
message: """
#^Call to deprecated function add_last_sql_error\\(\\)\\:
04/22/2023$#
"""
count: 1
path: app/cdash/app/Model/CoverageSummaryDiff.php

-
message: """
#^Call to deprecated method executePrepared\\(\\) of class CDash\\\\Database\\:
04/22/2023 Use Laravel query builder or Eloquent instead$#
"""
count: 2
path: app/cdash/app/Model/CoverageSummaryDiff.php

-
message: """
#^Call to deprecated method executePreparedSingleRow\\(\\) of class CDash\\\\Database\\:
04/22/2023 Use Laravel query builder or Eloquent instead$#
"""
count: 2
path: app/cdash/app/Model/CoverageSummaryDiff.php

-
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
count: 1
path: app/cdash/app/Model/CoverageSummaryDiff.php

-
message: "#^Property CDash\\\\Model\\\\CoverageSummaryDiff\\:\\:\\$BuildId has no type specified\\.$#"
count: 1
path: app/cdash/app/Model/CoverageSummaryDiff.php

-
message: "#^Property CDash\\\\Model\\\\CoverageSummaryDiff\\:\\:\\$LocTested has no type specified\\.$#"
count: 1
path: app/cdash/app/Model/CoverageSummaryDiff.php

-
message: "#^Property CDash\\\\Model\\\\CoverageSummaryDiff\\:\\:\\$LocUntested has no type specified\\.$#"
count: 1
path: app/cdash/app/Model/CoverageSummaryDiff.php

-
message: """
#^Call to deprecated function add_last_sql_error\\(\\)\\:
Expand Down

0 comments on commit fc705da

Please sign in to comment.