Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.0] Correct dashboard "Failed Jobs Past 7 Days" metric #633

Merged
merged 1 commit into from
Jul 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions resources/js/screens/dashboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@
/**
* Determine the recently failed job period label.
*/
recentlyFailedPeriod() {
failedJobsPeriod() {
return !this.ready
? 'Failed jobs past 7 days'
: `Failed jobs past ${this.determinePeriod(this.stats.periods.recentlyFailed)}`;
: `Failed jobs past ${this.determinePeriod(this.stats.periods.failedJobs)}`;
},
},

Expand Down Expand Up @@ -184,10 +184,10 @@

<div class="w-25 border-right border-bottom">
<div class="p-4">
<small class="text-uppercase" v-text="recentlyFailedPeriod"></small>
<small class="text-uppercase" v-text="failedJobsPeriod"></small>

<h4 class="mt-4 mb-0">
{{ stats.recentlyFailed ? stats.recentlyFailed.toLocaleString() : 0 }}
{{ stats.failedJobs ? stats.failedJobs.toLocaleString() : 0 }}
</h4>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/Http/Controllers/DashboardStatsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ public function index()
'processes' => $this->totalProcessCount(),
'queueWithMaxRuntime' => app(MetricsRepository::class)->queueWithMaximumRuntime(),
'queueWithMaxThroughput' => app(MetricsRepository::class)->queueWithMaximumThroughput(),
'recentlyFailed' => app(JobRepository::class)->countRecentlyFailed(),
'failedJobs' => app(JobRepository::class)->countFailed(),
'recentJobs' => app(JobRepository::class)->countRecent(),
'status' => $this->currentStatus(),
'wait' => collect(app(WaitTimeCalculator::class)->calculate())->take(1),
'periods' => [
'failedJobs' => config('horizon.trim.failed'),
'recentJobs' => config('horizon.trim.recent'),
'recentlyFailed' => config('horizon.trim.failed'),
],
];
}
Expand Down
6 changes: 3 additions & 3 deletions tests/Controller/DashboardStatsControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function test_all_stats_are_correctly_returned()
$this->app->instance(MetricsRepository::class, $metrics);

$jobs = Mockery::mock(JobRepository::class);
$jobs->shouldReceive('countRecentlyFailed')->andReturn(1);
$jobs->shouldReceive('countFailed')->andReturn(1);
$jobs->shouldReceive('countRecent')->andReturn(1);
$this->app->instance(JobRepository::class, $jobs);

Expand All @@ -58,13 +58,13 @@ public function test_all_stats_are_correctly_returned()
'wait' => ['first' => 20],
'processes' => 30,
'status' => 'inactive',
'recentlyFailed' => 1,
'failedJobs' => 1,
'recentJobs' => 1,
'queueWithMaxRuntime' => 'default',
'queueWithMaxThroughput' => 'default',
'periods' => [
'failedJobs' => 10080,
'recentJobs' => 60,
'recentlyFailed' => 10080,
],
]);
}
Expand Down