Skip to content

Commit

Permalink
adding more statistics to the onboarding page.
Browse files Browse the repository at this point in the history
  • Loading branch information
robertbrowncc committed Jun 4, 2024
1 parent 1548845 commit c467f63
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
8 changes: 7 additions & 1 deletion app/Http/Controllers/OnboardingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

namespace App\Http\Controllers;

use App\Models\PersonalAccessToken;
use App\Models\Platform;
use App\Services\StatementSearchService;
use Illuminate\Http\Request;
use Illuminate\Support\Carbon;

class OnboardingController extends Controller
{
Expand All @@ -17,12 +19,16 @@ public function index(Request $request)
{
$vlop_count = Platform::Vlops()->count();
$platforms = Platform::nonVlops()->with('users')->orderBy('name')->get();
$total_vlop_platforms_sending = $this->statement_search_service->totalVlopPlatformsSending();
$total_non_vlop_platforms_sending = $this->statement_search_service->totalNonVlopPlatformsSending();
$total_valid_tokens = PersonalAccessToken::query()->orWhereNull('expires_at')->orwhere('expires_at', '>=', Carbon::now())->count();

return view('onboarding.index', [
'platforms' => $platforms,
'vlop_count' => $vlop_count,
'total_non_vlop_platforms_sending' => $total_non_vlop_platforms_sending
'total_vlop_platforms_sending' => $total_vlop_platforms_sending,
'total_non_vlop_platforms_sending' => $total_non_vlop_platforms_sending,
'total_valid_tokens' => $total_valid_tokens
]);

}
Expand Down
12 changes: 11 additions & 1 deletion app/Services/StatementSearchService.php
Original file line number Diff line number Diff line change
Expand Up @@ -393,14 +393,24 @@ public function bulkIndexStatements(Collection $statements): void

public function totalNonVlopPlatformsSending()
{
return Cache::remember('total_sending_platforms', self::FIVE_MINUTES, function(){
return Cache::remember('total_sending_non_vlop_platforms', self::FIVE_MINUTES, function(){
$vlop_platform_ids = implode(',', Platform::Vlops()->pluck('id')->toArray());
$query = "SELECT COUNT(DISTINCT(platform_id)) FROM " . $this->index_name . " WHERE platform_id NOT IN (" . $vlop_platform_ids . ")";
$result = $this->runSql($query);
return $this->extractCountQueryResult($result);
});
}

public function totalVlopPlatformsSending()
{
return Cache::remember('total_sending_vlop_platforms', self::FIVE_MINUTES, function(){
$vlop_platform_ids = implode(',', Platform::Vlops()->pluck('id')->toArray());
$query = "SELECT COUNT(DISTINCT(platform_id)) FROM " . $this->index_name . " WHERE platform_id IN (" . $vlop_platform_ids . ")";
$result = $this->runSql($query);
return $this->extractCountQueryResult($result);
});
}


public function startCountQuery(): string
{
Expand Down
18 changes: 18 additions & 0 deletions resources/views/onboarding/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@
{{ $vlop_count }}
</td>
</tr>
<tr class="ecl-table__row">
<td class="ecl-table__cell" data-ecl-table-header="Statistic">
VLOP Platforms that have sent data via API or webform
</td>
<td class="ecl-table__cell" data-ecl-table-header="Total">
{{ $total_vlop_platforms_sending }}
</td>
</tr>

<tr class="ecl-table__row">
<td class="ecl-table__cell" data-ecl-table-header="Statistic">
Non-VLOP platforms
Expand All @@ -47,6 +56,15 @@
{{ $total_non_vlop_platforms_sending }}
</td>
</tr>

<tr class="ecl-table__row">
<td class="ecl-table__cell" data-ecl-table-header="Statistic">
Valid Tokens
</td>
<td class="ecl-table__cell" data-ecl-table-header="Total">
{{ $total_valid_tokens }}
</td>
</tr>
</tbody>
</table>
</div>
Expand Down

0 comments on commit c467f63

Please sign in to comment.