Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Feb 14, 2021
1 parent 9cbe57f commit b4e8c6a
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 11,820 deletions.
11,771 changes: 10 additions & 11,761 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/app-dark.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/app.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/app.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions public/mix-manifest.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"/app.js": "/app.js?id=30865fb89488803d192a",
"/app.css": "/app.css?id=1dac05f3a17f5e92eea7",
"/app-dark.css": "/app-dark.css?id=821c845f9bf3b7853c33"
"/app.js": "/app.js?id=748961c604302b4c2389",
"/app.css": "/app.css?id=58229b999b8f6c26fffe",
"/app-dark.css": "/app-dark.css?id=cc86d678620cebdafaa7"
}
49 changes: 26 additions & 23 deletions resources/js/screens/dashboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,12 @@
<div class="w-25 border-right">
<div class="p-4 mb-0">
<small class="text-uppercase">MAX WAIT TIME</small>
<small v-if="stats.max_wait_queue">({{ stats.max_wait_queue }})</small>

<h4 class="mt-4">
<h4 class="mt-4 mb-0">
{{ stats.max_wait_time ? humanTime(stats.max_wait_time) : '-' }}
</h4>

<small class="mt-1" v-if="stats.max_wait_queue">({{ stats.max_wait_queue }})</small>
</div>
</div>

Expand Down Expand Up @@ -278,27 +279,29 @@
</thead>

<tbody>
<template v-for="queue in workload">
<tr>
<td :class="{'font-weight-bold': queue.split_queues}">
<span>{{ queue.name.replace(/,/g, ', ') }}</span>
</td>
<td :class="{'font-weight-bold': queue.split_queues}">{{ queue.processes ? queue.processes.toLocaleString() : 0 }}</td>
<td :class="{'font-weight-bold': queue.split_queues}">{{ queue.length ? queue.length.toLocaleString() : 0 }}</td>
<td :class="{'font-weight-bold': queue.split_queues}" class="text-right">{{ humanTime(queue.wait) }}</td>
</tr>
<tr v-for="split_queue in queue.split_queues">
<td>
<svg class="icon info-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
<path d="M12.95 10.707l.707-.707L8 4.343 6.586 5.757 10.828 10l-4.242 4.243L8 15.657l4.95-4.95z"/>
</svg>
<span>{{ split_queue.name.replace(/,/g, ', ') }}</span>
</td>
<td>-</td>
<td>{{ split_queue.length ? split_queue.length.toLocaleString() : 0 }}</td>
<td class="text-right">{{ humanTime(split_queue.wait) }}</td>
</tr>
</template>
<template v-for="queue in workload">
<tr>
<td :class="{'font-weight-bold': queue.split_queues}">
<span>{{ queue.name.replace(/,/g, ', ') }}</span>
</td>
<td :class="{'font-weight-bold': queue.split_queues}">{{ queue.processes ? queue.processes.toLocaleString() : 0 }}</td>
<td :class="{'font-weight-bold': queue.split_queues}">{{ queue.length ? queue.length.toLocaleString() : 0 }}</td>
<td :class="{'font-weight-bold': queue.split_queues}" class="text-right">{{ humanTime(queue.wait) }}</td>
</tr>

<tr v-for="split_queue in queue.split_queues">
<td>
<svg class="icon info-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
<path d="M12.95 10.707l.707-.707L8 4.343 6.586 5.757 10.828 10l-4.242 4.243L8 15.657l4.95-4.95z"/>
</svg>

<span>{{ split_queue.name.replace(/,/g, ', ') }}</span>
</td>
<td>-</td>
<td>{{ split_queue.length ? split_queue.length.toLocaleString() : 0 }}</td>
<td class="text-right">{{ humanTime(split_queue.wait) }}</td>
</tr>
</template>
</tbody>
</table>
</div>
Expand Down
1 change: 1 addition & 0 deletions src/Repositories/RedisWorkloadRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public function get()
return collect($this->waitTime->calculate())
->map(function ($waitTime, $queue) use ($processes) {
[$connection, $queueName] = explode(':', $queue, 2);

$totalProcesses = $processes[$queue] ?? 0;

$length = ! Str::contains($queue, ',')
Expand Down
60 changes: 30 additions & 30 deletions src/WaitTimeCalculator.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,36 @@ public function calculate($queue = null)
})->sort()->reverse()->all();
}

/**
* Get all of the queue names.
*
* @param \Illuminate\Support\Collection $supervisors
* @param string|null $queue
* @return \Illuminate\Support\Collection
*/
protected function queueNames($supervisors, $queue = null)
{
$queues = $supervisors->map(function ($supervisor) {
return array_keys($supervisor->processes);
})->collapse()->unique()->values();

return $queue ? $queues->intersect([$queue]) : $queues;
}

/**
* Get the total process count for a given queue.
*
* @param \Illuminate\Support\Collection $allSupervisors
* @param string $queue
* @return int
*/
protected function totalProcessesFor($allSupervisors, $queue)
{
return $allSupervisors->sum(function ($supervisor) use ($queue) {
return $supervisor->processes[$queue] ?? 0;
});
}

/**
* Calculate the time to clear for the given queue in seconds distributed over the given amount of processes.
*
Expand All @@ -100,22 +130,6 @@ public function calculateTimeToClear($connection, $queue, $totalProcesses)
: round(($timeToClear / $totalProcesses) / 1000);
}

/**
* Get all of the queue names.
*
* @param \Illuminate\Support\Collection $supervisors
* @param string|null $queue
* @return \Illuminate\Support\Collection
*/
protected function queueNames($supervisors, $queue = null)
{
$queues = $supervisors->map(function ($supervisor) {
return array_keys($supervisor->processes);
})->collapse()->unique()->values();

return $queue ? $queues->intersect([$queue]) : $queues;
}

/**
* Get the total time to clear (in milliseconds) for a given queue.
*
Expand All @@ -129,18 +143,4 @@ protected function timeToClearFor($connection, $queue)

return $size * $this->metrics->runtimeForQueue($queue);
}

/**
* Get the total process count for a given queue.
*
* @param \Illuminate\Support\Collection $allSupervisors
* @param string $queue
* @return int
*/
protected function totalProcessesFor($allSupervisors, $queue)
{
return $allSupervisors->sum(function ($supervisor) use ($queue) {
return $supervisor->processes[$queue] ?? 0;
});
}
}

0 comments on commit b4e8c6a

Please sign in to comment.