Skip to content

Commit

Permalink
feat: added stats
Browse files Browse the repository at this point in the history
  • Loading branch information
stevan06v committed Sep 23, 2024
1 parent a72c9d4 commit d5f3834
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions resources/views/livewire/monitors/monitor-dashboard.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,39 @@
public function mount(Monitor $monitor)
{
$this->monitor = $monitor;
$this->calculate_statistics();
}
protected function calculate_statistics(): void
{
$this->total_repos = $this->monitor->repositories()->count();
$this->total_issues_open = $this->monitor->repositories->flatMap(function ($repo) {
return $repo->milestones->flatMap(function ($milestone) {
return $milestone->tasks->whereNotNull('closed_at');
});
})->count();
$this->total_issues_closed = $this->monitor->repositories->flatMap(function ($repo) {
return $repo->milestones->flatMap(function ($milestone) {
return $milestone->tasks->whereNull('closed_at');
});
})->count();
$this->top_milestones = $this->monitor->repositories->flatMap(function ($repo) {
return $repo->milestones;
})->sortByDesc('progress')->take(5);
$totalProgress = $this->monitor->repositories->flatMap(function ($repo) {
return $repo->milestones->pluck('progress');
})->sum() / 100;
$totalMilestones = $this->monitor->repositories->flatMap(function ($repo) {
return $repo->milestones;
})->count();
$this->total_percentage = $totalMilestones > 0 ? ($totalProgress / $totalMilestones) : 0;
}
}; ?>


Expand All @@ -25,6 +56,12 @@ public function mount(Monitor $monitor)
<h2 class="m-2 font-koulen text-3xl text-primary-blue">Overview</h2>
<div class="flex items-center justify-between mb-5">
{{$total_issues_closed}}
{{$total_issues_open}}

@foreach($top_milestones as $iterator)
{{$iterator->title}}
@endforeach

</div>
</div>
</div>

0 comments on commit d5f3834

Please sign in to comment.